Learn VisualLearn DB

Choose a Stable Identifier

A candidate key is a smallest set of attributes that uniquely identifies an entity, and the chosen candidate becomes the primary key. A natural key has meaning outside the database, while a surrogate key exists only to identify a row. The store uses stable integer ids for its main entities and the pair order_id plus product_id for OrderItem.

GOAL

Choose a stable primary key and recognize a composite key.

Why use customers.id as the primary key while keeping email UNIQUE?