Keys

Types of Keys

KeyDefinition
Super keyany set of columns that uniquely identifies a row
Candidate keya minimal super key (no column can be removed)
Primary keythe candidate key chosen as the main identifier
Alternate keya candidate key not chosen as primary (enforce with UNIQUE)
Composite keya key made of two or more columns
Foreign keya column referencing another table's key
Surrogate keyan artificial key (auto-increment, UUID)
Natural keya key with business meaning (email, ISBN)

Example

In Employees(EmployeeID, Email, PAN, Name): EmployeeID, Email and PAN are each candidate keys. EmployeeID is chosen as primary key (surrogate); Email and PAN are alternate keys with UNIQUE constraints; (EmployeeID, Name) is a super key but not a candidate key.