Describe PRIMARY KEY and how it differs from UNIQUE key
This deepens the constraint discussion by contrasting two uniqueness mechanisms. It tests precise definition knowledge.
Why Interviewers Ask This
Candidates often blur the lines between these two. Interviewers want to ensure clarity on NOT NULL requirements and quantity limits per table. This distinction is crucial for proper schema design.
How to Answer This Question
Define PRIMARY KEY as combining UNIQUE and NOT NULL properties. State that only one exists per table. Contrast with UNIQUE which allows NULLs and permits multiple constraints. Highlight the role of PK as the default target for foreign keys.
Key Points to Cover
- PK requires NOT NULL
- Only one PK allowed per table
- UNIQUE allows NULLs
- Multiple UNIQUE constraints permitted
Sample Answer
A PRIMARY KEY uniquely identifies each row and combines UNIQUE with NOT NULL properties. There can be only one primary key per table, though it can span multiple columns. A UNIQUE key enforces uniqueness but allows NULL…
Common Mistakes to Avoid
- Thinking UNIQUE cannot have NULLs
- Assuming multiple PKs are possible
- Ignoring foreign key relationships
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.