Friday, 15 May 2015

Few Basic Key of DBMS

a. Primary key – It is a set of one or more fields/columns of a table that uniquely identify a record in database table. It cannot accept null, duplicate values. Only one Candidate Key can be Primary Key.

b. Candidate key – It is a set of one or more fields/columns that can identify a record uniquely in a table. There can be multiple Candidate Keys in one table. Each Candidate Key can work as Primary Key.
Eg: In below diagram ID, Roll No. and Enroll No. are Candidate Keys since all these three fields can be work as Primary Key.

c. Alternate key – It is a key that can be work as a primary key. Basically, it is a candidate key that currently is not primary key.
Eg: In below diagram Roll No. and Enroll No. becomes Alternate Keys when we define ID as Primary Key.

 


ID
Roll No.
Name
Enroll No.
Address
Dept ID
1
6068741
Harsh
ADM1
Delhi
1
2
6068742
Neha
ADM2
Noida
1
3
6068743
Aditi
ADM3
Gurgaon
2
Primary Key

                             Alternate Keys

Possible Candidate Keys

                   

No comments: