Candidate Key – A Candidate Key can be any column or a
combination of columns that can qualify as unique key in database. There can be
multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary
Key.
Primary Key – A Primary Key is a column or a combination of
columns that uniquely identify a record. Only one Candidate Key can be Primary
Key.
One needs to be very careful in selecting the
Primary Key as an incorrect selection can adversely impact the database
architect and future normalization. For a Candidate Key to qualify as a Primary
Key. It may be possible that there are Candidate Keys that presently do not
contain value (not null) but technically they can contain null. It may be
possible that Candidate Keys that are unique at this moment may contain
duplicate value. These kinds of Candidate Keys do not qualify for Primary Key.
A table can have
multiple Candidate Keys that are unique as single column or combined multiple
columns to the table. They are all candidates for Primary Key. Candidate keys
that follow all the three rules – 1) Not Null, 2) Unique Value in Table and 3)
Static – are the best candidates for Primary Key. If there are multiple
candidate keys that are satisfying the criteria for Primary Key, the decision
should be made by experienced DBAs who should keep performance in mind.
No comments:
Post a Comment