Difference Between Super Key and Candidate Key
The difference between super key and candidate key is that a candidate key is a set of attributes that recognizes the tuples in relation or table, while a super key is a set of attributes or columns that uniquely identifies each row table. The difference between super key and candidate key are listed in the table below.
Super Key VS Candidate Key | |
Super Key | Candidate Key |
The set of attributes that uniquely identify a tuple in the relation. | The minimal set of attributes that identify a tuple uniquely in the relation. |
The number of super keys can be more than the candidate keys for a relation. | The number of candidate keys is less than the super keys for a relation. |
Every super key cannot be a candidate key. | Every candidate key is a super key. |
Null values can be taken by the attribute of a super key. | Null values are allowed for a candidate key. |
What is a Super Key?
A super key is the set of attributes that uniquely identify a tuple in the relation. A super key can find out using the candidate keys of the relation. This is the subtle difference between super key and candidate key. A super key is a superset of the candidate key.
Using the inclusion-exclusion principle formula, we can find the number of super keys for a relation with two or more candidate keys.
Download Formulas for GATE Computer Science Engineering - Algorithms
What is a Candidate Key?
A candidate key is defined as the minimal set of attributes that uniquely identify a tuple in the relation. There can be many candidate keys for a relationship. Some of the characteristics of the candidate keys are:
- A candidate key may allow null values.
- The primary key is chosen from one of the candidate keys.
- There can be many candidate keys for a relationship.
- The candidate key helps in finding the number of super keys.
Download Formulas for GATE Computer Science Engineering - Databases
Comments
write a comment