Give a suitable example of a table with sample data and illustrate Primary and Alternate Keys in it.
Primary Key: Primary key is a set of one or more fields/columns of a table that uniquely identify a record in the database table. It cannot accept null, duplicate values. Only one Candidate Key can be Primary Key.
Alternate key: the Alternate key is a key that can be work as a primary key. Basically, it is a candidate key that currently is not the primary key.
Example: In below table AdmissionNo becomes Alternate Keys when we define RegistrationNo as Primary Key.
Student Registration Table:
|
RegistrationNo |
AdmissionNo |
Name |
Phone |
Gender |
DOB |
|
CBSE4554 |
215647 |
Mihir Ranjan |
9568452325 |
Male |
1992-04-15 |
|
CBSE6985 |
265894 |
Amita Guha |
8456985445 |
Female |
1993-03-24 |
|
CBSE5668 |
458961 |
Rajesh Singh |
9654212440 |
Male |
1992-12-04 |
|
CBSE3654 |
469799 |
Mohit Patel |
7421589652 |
Male |
1992-05-16 |
Primary Key – Registration Number
Alternate Key – Admission No



