Difference between Super Key and Candidate Key

Prerequisite – Keys in Relational Model
Super Key:
Super Key is an attribute (or set of attributes) that is used to uniquely identifies all attributes in a relation. All super keys can’t be candidate keys but its reverse is true. In a relation, number of super keys are more than number of candidate keys.

Example:
We have a given relation R(A, B, C, D, E, F) and we shall check for being super keys by following given dependencies:

Functional dependencies         Super key
AB->CDEF                         YES
CD->AEF                          YES
CB->DF                           NO
D->BC                            NO 

By Using key AB we can identify rest of the attributes (CDEF) of the table. Similarly Key CD. But, by using key CB we can only identifies D and F not A and E. Similarly key D.

Candidate Key:
Candidate key is a set of attributes (or attribute) which uniquely identify the tuples in a relation or table. As we know that Primary key is a minimal super key, so there is one and only one primary key in any relation but there is more than one candidate key can take place. Candidate key’s attributes can contain NULL value which oppose to the primary key.
Example:

Student{ID, First_name, Last_name, Age, Sex, Phone_no} 

Here we can see the two candidate keys ID and {First_name, Last_name, DOB, Phone_no}. So here, there are present more than one candidate keys, which can uniquely identifies a tuple in a relation.

Difference between Super Key and Candidate Key:

S.NO Super Key Candidate Key
1. Super Key is an attribute (or set of attributes) that is used to uniquely identifies all attributes in a relation. Candidate Key is a proper subset of a super key.
2. All super keys can’t be candidate keys. But all candidate keys are super keys.
3. Various super keys together makes the criteria to select the candidate keys. Various candidate keys together makes the criteria to select the primary keys.
4. In a relation, number of super keys are more than number of candidate keys. While in a relation, number of candidate keys are less than number of super keys.
5. Super key’s attributes can contain NULL values. Candidate key’s attributes can also contain NULL values.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.