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.

Start playing free

  1. Unique and not null ✔
  2. Sorted and numeric
  3. 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.

The dad joke
My database rejected my duplicate key. It said: there can be only one.
Like this card?
Play the game

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.

  1. 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.

Test yourself in the game