Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Primary Key, Unique Key and candidate key

What is difference between Primary Key, Unique Key and candidate key?

like image 659
Ram Avatar asked Sep 01 '10 10:09

Ram


1 Answers

Super Key is the set of one or more column (ie attributes) which uniquely identifies a record.

Candidate key is a minimal Super key.(it mean we cant remove any attributes from it otherwise it will not remain Superkey anymore).

Primary Key is a arbitrary selected Candidate key. There must be only and only One primary key. We can choose any candidate key as a Primary key. Other candidate keys which are not chosen as Primary are called Alternate Keys.

If Primary Key have more then one column (or attributes) ,it is called Composite Key.

like image 171
saurabh kimothi Avatar answered Sep 29 '22 16:09

saurabh kimothi