Primary key

A primary identifier (PK) is the column, or combination of columns, whose value identifies each row of a database table uniquely and is never empty. Other tables refer to a row through its PK value.

Also called: primary keys · primary key constraint · PK

What it is

A primary identifier, abbreviated PK, is the column or set of columns that identifies each row of a database table uniquely. Its value is different for every row and is never missing. A table has at most one PK, which may be built from one column or from several columns together.

ISO/IEC 9075 (SQL) specifies how the integrity constraints of tables are defined. A PK is declared as such a constraint, so the database itself refuses a duplicate or empty value.

A PK can be:

Other tables refer to a row by storing its PK value in a column called a foreign identifier (FK). A NIST data glossary shows this pattern: a study identifier column in one table is an FK that matches the PK of the study table.

Why it matters

Joins rely on identifiers. If the PK is unique, a join returns one matching row per reference. If it is not, the join repeats rows and totals are inflated.

A PK also prevents duplicate records, so one customer or one trade is stored once.

Worked example

Illustrative numbers. An invoices table has the invoice number as its PK. It holds 1,000 rows with numbers 1 to 1,000.

An attempt to insert a second row with number 500 is rejected because the value already exists. An attempt to insert a row with no invoice number is also rejected.

A payments table stores the invoice number in an FK column. A payment that carries invoice number 500 therefore points to exactly one invoice row.

Who uses it

Common confusions

6Roles that need it

7Skills behind it

Sources behind this page (2) · Updated 5 Nov 2026

Concept