🗄️ Database Design / Normalization
Intermediate
What are database constraints and what types exist?
Answer
Database constraints enforce rules on the data stored in tables, ensuring integrity at the database level regardless of application code. Types: NOT NULL — column must have a value; UNIQUE — all values in a column (or group) must be distinct; PRIMARY KEY — uniquely identifies rows (NOT NULL + UNIQUE); FOREIGN KEY — referential integrity between tables; CHECK — custom condition must be true for all row values; DEFAULT — specifies a value when none is provided (technically not an integrity constraint). Constraints can be defined at column level (inline) or table level. Named constraints are easier to identify in error messages.
Previous
What is a deadlock in databases and how is it resolved?
Next
What is index selectivity and why does it matter?
More Database Design / Normalization Questions
View all →- Intermediate What are database anomalies and how does normalization prevent them?
- Intermediate What is denormalization and when is it used?
- Intermediate What are isolation levels in database transactions?
- Intermediate What are dirty reads, non-repeatable reads, and phantom reads?
- Intermediate What is query optimization and what is a query execution plan?