In database management systems, a Candidate Key is a minimal super key—a set of one or more attributes that can uniquely identify every row in a table, with no unnecessary attributes included. Candidate keys are extremely important in relational database design because the primary key is selected from the set of candidate keys.
A candidate key guarantees uniqueness while also being minimal.
What is a Candidate Key?
A candidate key is a set of attributes that satisfies two conditions:
1. Uniqueness
The attribute set must uniquely identify every row in the table.
No two rows can have the same values for the candidate key.
2. Minimality
No attribute can be removed from the key without losing uniqueness.
This means the key contains no redundant attributes.
Because of this minimality condition:
every candidate key is a super key
but not every super key is a candidate key
Example of a Candidate Key
Consider the following STUDENT table:
| Roll_No | Name | Branch | CGPA | |
|---|---|---|---|---|
| 101 | aman@email.com | Aman | CSE | 8.5 |
| 102 | riya@email.com | Riya | ECE | 7.9 |
| 103 | kunal@email.com | Kunal | ME | 8.1 |
In this table:
Roll_Nouniquely identifies each studentEmailalso uniquely identifies each student
So:
{Roll_No}is a candidate key{Email}is also a candidate key
Super Key vs Candidate Key
Consider these attribute sets:
Candidate Keys
{Roll_No}
{Email}
These are candidate keys because:
they uniquely identify rows
they are minimal
Super Keys but NOT Candidate Keys
{Roll_No, Name}
{Email, Branch}
These are super keys because they still uniquely identify rows.
However, they are not candidate keys because:
extra attributes (
Name,Branch) are unnecessaryremoving them still preserves uniqueness
Therefore, they violate minimality.
Composite Candidate Key
Sometimes uniqueness depends on multiple attributes together.
Example: ENROLLMENT table
| Roll_No | Course_ID | Semester | Grade |
|---|---|---|---|
| 101 | C101 | Fall2024 | A |
| 101 | C102 | Fall2024 | B |
| 102 | C101 | Fall2024 | B |
Here:
Roll_Noalone is not uniqueCourse_IDalone is not uniquebut
{Roll_No, Course_ID}together are unique
So:
{Roll_No, Course_ID}
is a composite candidate key.
Properties of Candidate Keys
1. Unique
Every candidate key must uniquely identify tuples.
2. Minimal
No attribute can be removed without losing uniqueness.
3. Multiple Candidate Keys Allowed
A table may have several candidate keys.
One of them is later chosen as the primary key.
4. Can Be Single or Composite
Candidate keys may contain:
one attribute
or multiple attributes
Candidate Key vs Super Key
| Feature | Super Key | Candidate Key |
|---|---|---|
| Uniquely identifies rows | Yes | Yes |
| Minimal | Not required | Required |
| Can contain extra attributes | Yes | No |
| Used for primary key selection | Not always | Yes |
Every candidate key is a super key, but not every super key is a candidate key.
Candidate Key vs Primary Key
| Feature | Candidate Key | Primary Key |
|---|---|---|
| Number allowed | Multiple | One |
| Uniqueness | Required | Required |
| NULL allowed | No | No |
| Selected as main identifier | Not necessarily | Yes |
From all candidate keys, the database designer selects one as the primary key.
The remaining candidate keys become alternate keys.
SQL Example
Here:
Roll_Nois a candidate keyEmailis also a candidate key
If the designer chooses Roll_No as the primary key:
Emailbecomes an alternate key
Why Candidate Keys Matter?
Candidate keys are important because they:
help uniquely identify records
reduce redundancy
support normalization
help choose the best primary key
improve indexing and searching
maintain data integrity
They are fundamental to relational schema design.
Choosing a Good Candidate Key
A good candidate key should be:
unique
minimal
stable
non-null
short if possible
Examples:
Roll_No
Email
Aadhaar_No
Employee_ID
Common Real-World Examples
| Table | Possible Candidate Keys |
|---|---|
| STUDENT | Roll_No, Email |
| EMPLOYEE | Employee_ID, Aadhaar_No |
| USER | Username, Email |
| VEHICLE | Registration_No, VIN |
Summary
A Candidate Key in DBMS is a minimal super key—a set of attributes that uniquely identifies every row in a table without containing unnecessary attributes. A table may have multiple candidate keys, and one of them is selected as the primary key. Candidate keys are essential in relational database design because they ensure uniqueness, support normalization, and form the basis for primary keys and alternate keys.