Senior Backend Interview: Databases — Normalization, Indexes and Transactions
1NF, 2NF, 3NF, composite indexes, ACID, isolation levels, N+1 and deadlocks — the answers every backend interview asks for.

Databases are the topic where it shows fastest whether someone runs production systems or has just read a tutorial. These are the answers I keep ready.
Normalization
1NF — every cell holds a single value, no repeating groups and no lists in a column. 2NF — 1NF plus no non-key column depends on only part of a composite primary key. 3NF — 2NF plus no non-key column depends on another non-key column.
In practice it means every piece of data lives in one place. In production I deliberately denormalize where reads become too expensive — but that is a decision, not an oversight.
An example of breaking 3NF
An orders table that stores customer_city next to customer_id. The city doesn't depend on the order but on the customer — that is a transitive dependency. If the customer moves, the old orders lie.
BCNF
A stricter version of 3NF — every determinant must be a candidate key. It rarely comes into play in practice.
Indexes
An index is a structure that speeds up lookups and slows down writes, because it has to be maintained. I put one on the columns I filter, sort and join by. I don't put one on low-cardinality columns — an index on a boolean is usually worthless.
Composite indexes and the leftmost prefix rule
In a composite index the column order matters. An index on (a, b) helps a query on a and on a AND b, but not a query on b alone.
Why an index isn't used
Most often because the column is wrapped in a function — WHERE DATE(created_at) = ... kills the index. Or the selectivity is so poor that the optimizer decides a full scan is cheaper.
ACID
- Atomicity — a transaction succeeds completely or not at all.
- Consistency — the database moves from one valid state to another.
- Isolation — concurrent transactions don't interfere with each other.
- Durability — once committed, it survives a server crash.
Isolation levels
MySQL defaults to REPEATABLE READ. READ COMMITTED sees other transactions' committed changes mid-transaction, REPEATABLE READ doesn't. SERIALIZABLE is the strictest and the most expensive. I rarely change them in practice, but with reports and long transactions it can matter.
JOINs
INNER returns only matching rows. LEFT returns everything from the left table plus the matches from the right, the rest is NULL. RIGHT is the reverse. FULL OUTER returns everything from both sides — MySQL doesn't have it, you do it with a UNION.
The N+1 problem
When you fetch a list and then run a new query for every row in a loop — one query for the list and N for the details. The fix is eager loading, with() in Laravel, or a JOIN or a single IN query.
$posts = Post::with('author', 'tags')->latest()->paginate();
Transactions vs locking
A transaction groups operations. Locking prevents someone from changing the data while you are working with it. I use SELECT ... FOR UPDATE when I have to read and then write based on what I read — otherwise you get a lost update.
Deadlock
Two transactions wait for each other. The database detects it and kills one of them. You avoid it by always locking resources in the same order and keeping transactions short.