different types of keys in dbms

different types of keys in dbms


Key is the column or set of columns that can be use to uniquely identify the records/tuples in a table. 
There can be a possibility of multiple SuperKey in a relation/table.

Candidate key: 
The minimal SuperKey is considered as a candidate key.
There can be possibility of multiple candidate-key in a table.

Primary key

Among multiple candidate key Database Administrator can choose only one key as a Primary key.

    Example: Suppose a table (Rel1) is having multiple unique columns as below.
Rel1 (SSN, PAN, PASSPORTNO, Description)

“Database Administrator” or “Database Architect” can choose any unique column which do not have any NULL values in it as Primary Key.

Unique key: 

Unique key is the key column or combination of columns with a maximum of one NULL value in it.

In short- Primary Key is having a column or combination of columns which is UNIQUE and NOT NULL. Where as a Unique key can have all UNIQUE values with maximum of a single NULL .

Leave a Comment

Your email address will not be published. Required fields are marked *