Define Candidate Key ?

 Posted by Bharathi Cherukuri on 4/30/2012 | Category: Sql Server Interview questions | Views: 5294 | Points: 40

A candidate key is a key which can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table. If the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys.


CREATE TABLE Appointments (

ClientID int not null,
CounsellorID int not null,
RoomID int not null,
AppointmentTime datetime not null

The candidate keys for this table are {ClientID,AppointmentTime}, {CounsellorID,AppointmentTime} and {RoomID,AppointmentTime}. Any of those combinations of columns could be used to uniquely identify a row in the table, and all of them are composite keys.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response