What is normalization, and what are primary and foreign keys?
What they are really testing: Whether you understand reducing redundancy and the role of keys in relational integrity, and that denormalization is a deliberate performance trade-off, not just a mistake.
A real interview question
What is normalization, and what are primary and foreign keys?
What most people say
drag me
“Normalization splits data into tables, and keys link the tables together.”
It gestures at the idea but does not explain why (reducing redundancy and anomalies), what each key actually enforces, or that denormalization is a legitimate performance trade-off.
The follow-ups they ask next
When would you deliberately denormalize?
For read-heavy access patterns where joins are too expensive, you duplicate data (or precompute a read model) to serve reads fast, accepting redundancy and the cost of keeping copies in sync. It is a performance trade-off, not a mistake.
What does a foreign key constraint protect against?
Orphaned/invalid references: you cannot insert a row referencing a non-existent parent, and deletes are controlled (cascade/restrict/set null). It enforces referential integrity at the database level.
What the interviewer is listening for
- Normalization = reduce redundancy/anomalies
- PK uniquely identifies, FK enforces referential integrity
- Knows denormalization is a deliberate trade-off
What sinks the answer
- Vague "split into tables"
- Cannot say what keys enforce
- Thinks denormalization is always wrong
If you genuinely do not know
Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.
“Normalization [stores each fact once to reduce redundancy and update anomalies]. A [primary key uniquely identifies a row]; a [foreign key references another table PK, enforcing referential integrity, no orphan rows, controlled deletes]. [Denormalization is a deliberate trade-off: duplicate data to avoid joins and speed reads, accepting you must keep copies in sync].”
Keep going with databases
Foundation
What is a database index, how does it speed up queries, and what does it cost?
Foundation
What are the ACID properties of a database transaction?
Junior
A query is slow in production. How do you diagnose and fix it?
Junior
Why is database connection pooling important, especially at scale?
Junior
How do read replicas help scale a database, and what is replication lag?
Mid
Under load, your RDS instance is the bottleneck and the app is slowing down. Walk me through your options, in order.
Knowing the answer is not the same as recalling it under pressure
Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.
Start free