🗃️Primary Key
Also known as PK, Primary Key Column
A column with a different value in each row. That is how one row is found.
Think of it like
Think of it like the number on a shirt in a team. Two kids can share a name, but not a number.
Example
Two customers are both called Jack. Their ids are 2 and 7, so the shop never sends the wrong one an order.
Why it matters
Definition
Example code
sql
INSERT INTO customers (id, name) VALUES (1, 'Zoe');
-- Error: UNIQUE constraint failed: customers.idCommon mistake
Key takeaways
- 1Unique. No two rows share it.
- 2Never empty. Every row must have one.
- 3Never changes. Other tables rely on it.