Keys in DBMS


☞ Keys allow us to identify an attribute or a set of attributes on the on the basis of which a table is identified.

☞ They are used to establish and identify relation among two or more tables.

☞ The different types of keys in a RDBMS are as follows :

1. Primary Key
2. Candidate Key
3. Alternate Key
4. Foreign Key

Primary Key

☞ It is a set of one or more attributes/fields which uniquely identifies a tuple/row in a table.

☞ It is unique in nature.

☞ It arranges the table in its own order.

☞ It cannot be left null.

☞ One table can have only one primary key


Candidate Key

☞ It refers to all the attributes in a relation that are candidates or are capable of becoming a primary key.


Alternate Key

☞ A candidate key that is not the primary key is called an alternate key.

Alternate key = Candidate keys - Primary key


Foreign Key

☞ It is a non-key attribute whose value is derived from the primary key of another table.