Describe a PRIMARY KEY and how it differs from a UNIQUE key

SQL
Medium
148.1K views

This question probes the nuances of identification constraints. It tests deep understanding of database rules.

Why Interviewers Ask This

It distinguishes between basic uniqueness and strict identity. Interviewers check if you know that a primary key implies NOT NULL and is unique per table. This is crucial for designing robust schemas.

How to Answer This Question

Define PRIMARY KEY as UNIQUE plus NOT NULL. State there can only be one per table. Contrast with UNIQUE which allows NULLs and permits multiple constraints. Mention foreign key dependencies.

Key Points to Cover

  • Primary Key is NOT NULL
  • Only one Primary Key allowed
  • Unique allows NULLs
  • Foreign Keys reference Primary Key

Sample Answer

A PRIMARY KEY uniquely identifies each row and combines UNIQUE with NOT NULL. There can be only one primary key per table, though it can span multiple columns. A UNIQUE key enforces uniqueness but allows NULL values and…

Common Mistakes to Avoid

  • Thinking Unique cannot have NULLs
  • Believing multiple Primary Keys are allowed
  • Ignoring the NOT NULL requirement

Sound confident on this question in 5 minutes

Answer once and get a 30-second AI critique of your structure, content, and delivery. First attempt is free — no signup needed.

Try it free

Related Interview Questions

Browse all 101 SQL questions