Keys in RDBMS

Keys in RDBMS

KEYS in RDBMS: Primary Key, Candidate Key, Super Key


  • Super Keys
  • Candidate Key
  • Primary Key
Super Keys : Super key stands for superset of a key.
A Super Key is  a set of one or more attributes that are taken collectively and can identify all other attributes uniquely.

Candidate Keys
Candidate Keys are  super keys for which no proper subset is a super key. In other words candidate keys are minimal super keys.

Primary Key:
It is a candidate key that is chosen by the database designer to identify entities with in an entity set. Primary key is the minimal super keys. In the ER diagram primary key is represented by underlining the primary key attribute. Ideally a primary  key is composed of only a single attribute. But it is possible to have a  primary key composed of more than one attribute.
Composite Key
Composite  key consists of more than one attributes.

Example: Consider a Relation or Table R1. Let A,B,C,D,E are the attributes of this relation.
A→BCDE   This means the attribute 'A' uniquely determines the other attributes B,C,D,E.
BC→ADE   This means the attributes 'BC' jointly determines all the other attributes A,D,E in the relation.

Primary Key  :A                         
Candidate Keys  :A, BC
Super Keys : A,BC,ABC,AD

ABC,AD are not Candidate Keys since both are not minimal super keys.