DBMS: Keys

Super Key

Definition: A super key is a set or one of more columns (attributes) to uniquely identify rows in a table. Often people get confused between super key and candidate key, so we will also discuss a little about candidate key here.

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: Employee table

Emp_SSN Emp_Number Emp_Name
123456789 226                         Steve
999999321 227                         Ajeet
888997212 228                         Chaitanya
777778888 229                         Robert

Super keys:
{Emp_SSN}
{Emp_Number}
{Emp_SSN, Emp_Number}
{Emp_SSN, Emp_Name}
{Emp_SSN, Emp_Number, Emp_Name}
{Emp_Number, Emp_Name}
All of the above sets are able to uniquely identify rows of the employee table.




Candidate Keys:
As I stated above, they are the minimal super keys with no redundant attributes.

{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.

Primary key:
Primary key is being selected from the sets of candidate keys by database designer. So Either {Emp_SSN} or {Emp_Number} can be the primary key.

Source: https://beginnersbook.com/2015/04/super-key-in-dbms/






Facebook Page: fb.me/mohitsinghkush700

Comments

Popular Posts