Skip to content
Commitwise
Menu

Primary key

Also called: PK

The column (or columns) that uniquely identifies each row of a table; never empty, never repeated.

Definition

The database enforces that primary key values are unique and NOT NULL, and builds an index on them. Most tables use a surrogate key, a number or UUID the system generates, rather than a natural value like an email, because the key must never change: other tables point at it through foreign keys.

In practice

customers.id is 42 for Ana, and every order she places stores customer_id = 42.

Learn it in context

Lessons that use this term.

Related terms

Esc

Type to search the whole site.