Data engineering and IT

Primary key

  • Data engineering and IT

Definition

A column, or set of columns, whose values uniquely identify each row in a table and are never empty.

Example

In Raket Parts B.V. data, customer_ref is the primary key of the customers table: 436 rows and 436 different values, none blank. Order lines need two columns together, so_ref and line_no, because one order has several lines.

Raket Parts B.V. is a fictional company created for Insyt.

See how it works

Customer recordcustomer_id = 1001
Different customer recordcustomer_id = 1002

A primary key must uniquely identify each row in its table and cannot be null.

Check your understanding

Common mistake: A primary key identifies a record within its table; it does not necessarily reconcile the same real-world person across multiple systems.

Can two rows in one table have the same primary-key value?

Show explanation

No, not if the database enforces the primary-key constraint.

For your role

Choose your role to see what this term means in your work.

Why it matters

Without a reliable key, records can be duplicated or confused and joins give wrong totals.

Where it is used

Database design, data models and data quality checks. Used by data engineers, BI developers, database administrators and data analysts.