Super Key in DBMS

Rumman Ansari   Software Engineer   2023-03-23   6104 Share
☰ Table of Contents

Table of Content:


A super key is a set of one or more attributes (columns), which can uniquely identify a row in a table. Often DBMS beginners get confused between super key and candidate key, so we will also discuss candidate key and its relation with super key in this article.

Super Key is defined as a set of attributes within a table that can uniquely identify each record within a table. Super Key is a superset of Candidate key.

How candidate key is different from super key?

Answer is simple – Candidate keys are selected from the set of super keys, the only thing we take care while selecting candidate key is: It should not have any redundant attribute. That’s the reason they are also termed as minimal super key.

Let’s take an example to understand this:
Table: Employee

Emp_SSN

    Emp_Number

 Emp_Name

123456789

226

 Steve

999999321

227

 Ajeet

888997212

228

 Chaitanya

777778888

229

 Robert

Super keys: The above table has following super keys. All of the following sets of super key are able to uniquely identify a row of the employee table.

  • {Emp_SSN}
  • {Emp_Number}
  • {Emp_SSN, Emp_Number}
  • {Emp_SSN, Emp_Name}
  • {Emp_SSN, Emp_Number, Emp_Name}
  • {Emp_Number, Emp_Name}

Candidate Keys: As I mentioned in the beginning, a candidate key is a minimal super key with no redundant attributes. The following two set of super keys are chosen from the above sets as there are no redundant attributes in these sets.

  • {Emp_SSN}
  • {Emp_Number}

Only these two sets are candidate keys as all other sets are having redundant attributes that are not necessary for unique identification.

Super key vs Candidate Key

1. First you have to understand that all the candidate keys are super keys. This is because the candidate keys are chosen out of the super keys.
2. How we choose candidate keys from the set of super keys? We look for those keys from which we cannot remove any fields. In the above example, we have not chosen {Emp_SSN, Emp_Name} as candidate key because {Emp_SSN} alone can identify a unique row in the table and Emp_Name is redundant.

Primary key:
A Primary key is selected from a set of candidate keys. This is done by database admin or database designer. We can say that either {Emp_SSN} or {Emp_Number} can be chosen as a primary key for the table Employee.