Difference Between Super key and Candidate Key in SQL
Advertisements
Difference Between Candidate Key and Super key in SQL
A DBMS key is an attribute or set of an attribute which helps you to identify a row(tuple) in a relation(table).
Super key is any combination of columns which uniquely identify a row in the table. Candidate key is minimal super key from which you cannot remove any fields else it will not be able to uniqule identify the rows. We can say that candidate key is the proper subset of super key
Employee Table
Let's take example of an Employee table: Employee ( Employee ID, FullName, SSN, DeptID )
Here Candidate Key: are individual columns in a table that qualifies for uniqueness of all the rows. Here in Employee table EmployeeID & SSN are Candidate keys.
And Super Key: If you add any other column/attribute to a Primary Key then it become a super key, like EmployeeID + FullName is a Super Key.
Difference Between Candidate Key and Super key in SQL
Candidate Key | Super Key |
---|---|
It can be a column or combination of columns which can be qualify as Unique key. A table can have more than one candidate key, but only one candidate key can be primary key. | A super key is a set or one of more columns to uniquely identify rows in a table. |
Candidate key is minimal super key from which you cannot remove any fields else it will not be able to uniqule identify the rows. We can say that candidate key is the proper subset of super key. | Super key is any combination of columns which uniquely identify a row in the table. |
While in a relation, number of candidate keys are less than number of super keys | In a relation, number of super keys are more than number of candidate keys |
dddLanguage | DMLionanguage |
Candidate key's attributes can also contain NULL values | Super key's attributes can contain NULL values |
Candidate Key is a proper subset of a super key. | Super Key is an attribute (or set of attributes) that is used to uniquely identifies all attributes in a relation. |
All candidate keys are super keys. | All super keys can't be candidate keys |
Various candidate keys together makes the criteria to select the primary keys. | Various super keys together makes the criteria to select the candidate keys |
Google Advertisment