Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Super Key in RDBMS
A Super Key is an attribute (or a set of attributes) that uniquely identifies a tuple (row) in a table. Any combination of columns that can uniquely identify each row is a super key. It is a superset of Candidate Key, since candidate keys are the minimal super keys with no redundant attributes.
Example
Consider the following Student table ?
| Student_ID | Student_Enroll | Student_Name | Student_Email |
|---|---|---|---|
| S02 | 4545 | Dave | ddd@gmail.com |
| S34 | 4541 | Jack | jjj@gmail.com |
| S22 | 4555 | Mark | mmm@gmail.com |
Super Keys
The following are some of the super keys for the above table. Any combination containing a unique column qualifies ?
{Student_ID}
{Student_Enroll}
{Student_Email}
{Student_ID, Student_Enroll}
{Student_ID, Student_Name}
{Student_ID, Student_Email}
{Student_Name, Student_Enroll}
{Student_ID, Student_Enroll, Student_Name}
{Student_ID, Student_Enroll, Student_Email}
{Student_ID, Student_Enroll, Student_Name, Student_Email}
Candidate Keys
Candidate keys are the minimal super keys − super keys from which no attribute can be removed without losing uniqueness ?
{Student_ID}
{Student_Enroll}
{Student_Email}
Note − {Student_ID, Student_Name} is a super key but not a candidate key because removing Student_Name still leaves {Student_ID} which is unique on its own. Candidate keys have no redundant attributes.
Relationship
Conclusion
A super key is any combination of columns that uniquely identifies each row. Candidate keys are the minimal super keys with no redundant attributes, and one candidate key is chosen as the primary key. Every candidate key is a super key, but not every super key is a candidate key.
