All posts
postMay 24, 2026

What is a primary key?

#sql#primary-key#data-modeling
What is a primary key and why does every table need one?

The column (or set of columns) that uniquely identifies each row. Like a national ID number for citizens — no two share it, and it cannot be empty. Without a primary key, you cannot reliably update a single row, join tables, or detect duplicates.

A primary key is the column (or set of columns) that uniquely identifies each row in a table. Two rows can never share the same primary key value, and a primary key cannot be null.

In data engineering you check primary keys constantly. When ingesting data, you verify it is unique — duplicates indicate a broken upstream source. When joining tables, you usually join on a primary key from one side. Designing a good primary key is one of the first decisions in any data model.