Skip to content

Computer Science · Ch 8 — Database Concepts

Primary Key

8.5.2

Primary Key

A primary key is the single candidate key that the database designer selects to serve as the unique identifier for every row in a relation. Out of all the candidate keys available, only one gets promoted to primary key status.

The remaining candidate keys — the ones not chosen as the primary key — are called alternate keys. They are still unique and valid, but they are not used as the main identifier.

For example, in the relation GUARDIAN, suppose the designer chooses GUID as the primary key. Then GPhone, which was also a candidate key, becomes an alternate key.

Important

A primary key must be chosen from the set of candidate keys. It is the designer's decision which one to pick, based on factors like stability, simplicity, and usage frequency.

  • Every tuple in the relation is uniquely identified by the primary key value.
  • No two rows can have the same primary key value.
  • The primary key cannot be NULL — every row must have a valid primary key value. …