SESK: Stuff Everyone Should Know · sesk.info/tech-primary-key
In a relational database, what two rules does a primary key enforce?
Unique and not null: every row has one, and no two rows share it.
- Unique and not null ✔
- Sorted and numeric
- Encrypted and hidden
Why: A primary key identifies each row, like a student ID number. Its value must be unique so it identifies exactly one row, and it cannot be null.
Huh, didn't know that: A foreign key can reference a primary key or another unique key, maintaining referential integrity.
My database rejected my duplicate key. It said: there can be only one.
Like this card?
References
Answer: Unique and not null. A primary key identifies each row, like a student ID number. Its value must be unique so it identifies exactly one row, and it cannot be null.
- PostgreSQL Documentation: Constraints www.postgresql.org/docs/current/ddl-constraints.html
This requires that the values be both unique and not null.
Checked 2026-10-10.
Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.
More stuff everyone should know
That's stuff everyone should know.