What is the purpose of the UNIQUE constraint?
This question focuses on data integrity mechanisms within relational databases. It tests knowledge of enforcing distinct values.
Why Interviewers Ask This
Interviewers need to confirm you understand how to prevent duplicate data entry. Data integrity is critical for business logic, and this constraint is a primary tool for maintaining it. They also check if you know how it differs from a primary key.
How to Answer This Question
State clearly that the constraint ensures all values in a column or combination are distinct. Explain its role in preventing duplicates. Briefly contrast it with the PRIMARY KEY constraint regarding NULL values and multiplicity per table.
Key Points to Cover
- Ensures distinct values
- Prevents duplicate data
- Allows multiple NULLs
- Maintains data integrity
Sample Answer
The UNIQUE constraint ensures that all values in a column or a combination of columns are distinct across the entire table. This prevents duplicate entries and helps maintain high data integrity. Unlike a primary key, a…
Common Mistakes to Avoid
- Confusing it with PRIMARY KEY entirely
- Forgetting it allows NULLs
- Not mentioning composite uniqueness
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.