Prerequisite – Keys in Relational Model
1. 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->ABEF 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.
2. Primary Key:
Candidate key is a set of attributes (or attribute) which uniquely identify the tuples in a relation or table. There can be more than one candidate key in relation out of which one can be chosen as the primary key.
Example:
Student{Stud_No, Stud_name, Stud_phone,
Stud_state, Stud_country, Stud_age}
Here we can see the two candidate keys Stud_No and Stud_phone. STUD_No can be chosen as the primary key (only one out of many candidate keys).
Difference between Super Key and Primary Key:
| S.NO | Super Key | Primary Key |
|---|---|---|
| 1. | Super Key is an attribute (or set of attributes) that is used to uniquely identifies all attributes in a relation. | Primary Key is a minimal set of attribute (or set of attributes) that is used to uniquely identifies all attributes in a relation. |
| 2. | All super keys can’t be primary keys. | Primary key is a minimal super key. |
| 3. | Various super keys together makes the criteria to select the candidate keys. | We can choose any of the minimal candidate key to be a primary key. |
| 4. | In a relation, number of super keys are more than number of primary keys. | While in a relation, number of primary keys are less than number of super keys. |
| 5. | Super key’s attributes can contain NULL values. | Primary key’s attributes cannot contain NULL values. |
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
Recommended Posts:
- Difference between Primary key and Unique key
- Difference between Primary Key and Foreign Key
- Difference between super and super() in Java with Examples
- Types of Keys in Relational Model (Candidate, Super, Primary, Alternate and Foreign)
- Difference between Super Key and Candidate Key
- Difference between Primary and Candidate Key
- Difference between Primary and Secondary Memory
- Difference between Primary and Secondary Data
- Difference between super() and this() in java
- Difference between Private key and Public key
- How to fade in color button from btn-primary to btn-success?
- Primary Indexing in Databases
- Calling A Super Class Constructor in Scala
- JavaScript | Super keyword
- Calling a Super Class Constructor in Python
- How to make a key fire when key is pressed using JavaScript ?
- Difference Between Symmetric and Asymmetric Key Encryption
- How to loop through an associative array and get the key in PHP?
- How to remove a key and its value from an associative array in PHP ?
- How to create dictionary and add key–value pairs dynamically?
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.

