×
>
<

DBMS

DBMS Key Candidate | CrackEase

Candidate Key in DBMS

Candidate Key

A candidate key is a minimal super key — that is, a set of attributes that uniquely identifies each row in a table and contains no redundant attributes. Candidate keys are chosen from the set of super keys; each candidate key is a potential primary key.

In short: candidate key = minimal super key.

Properties

  • Uniqueness: A candidate key must uniquely identify each row.
  • Minimality: It contains no unnecessary attributes — removing any attribute breaks uniqueness.
  • No NULLs: Candidate key attributes should not contain NULL values (to ensure uniqueness for every row).
  • Multiple candidate keys: A table can have more than one candidate key; one of them is chosen as the primary key.

IDNAMEPHONE
66Elena9789578575
67Haley8758273875
68Alex7847326558
69Elena7923857563

Steps to find candidate keys from the table:

  1. List all super keys (sets of attributes that can uniquely identify rows).
  2. From those, eliminate any key that contains redundant attributes (i.e., you can remove an attribute and still have uniqueness).
  3. The remaining minimal keys are the candidate keys.

Using the table above:

  1. {ID} — ID is unique for every row, so {ID} is a candidate key.
  2. {PHONE} — PHONE is unique for every row, so {PHONE} is a candidate key.
  3. {ID, PHONE} — also identifies rows but is not minimal (both attributes together are redundant since {ID} alone suffices), so it's a super key but not a candidate key.
  4. {ID, NAME} — not minimal because {ID} alone works; therefore not a candidate key.

Candidate keys in this example:

  • {ID}
  • {PHONE}
Candidate key versus Super key

  • Every candidate key is a super key, but a super key may contain extra attributes and therefore might not be minimal.
  • To convert a super key into a candidate key you remove any redundant attributes until minimality is achieved.

Footer Content | CrackEase