Describe a PRIMARY KEY and how it differs from a UNIQUE key
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 you can have many UNIQUE constraints per table.
Common Mistakes to Avoid
- Thinking Unique cannot have NULLs
- Believing multiple Primary Keys are allowed
- Ignoring the NOT NULL requirement
Practice This Question with AI
Answer this question orally or via text and get instant AI-powered feedback on your response quality, structure, and delivery.
Related Interview Questions
What is ER model in the DBMS?
Medium
FlipkartWhat is Join and explain its types?
Medium
FlipkartWhat is the difference between LIKE and equals operators in SQL?
Easy
TCSWhat is the difference between UNION and UNION ALL?
Easy
What is the ER model in DBMS?
Easy
FlipkartWhat is database normalization and why is it important?
Medium
Flipkart