Interview Q&A · questions with model answers
Databases & Transactions Interview Questions
Part of the study plan for: Backend Engineer · Full Stack Engineer · Data Engineer
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked Explain transaction isolation levels and the anomalies they prevent.
Read Uncommitted allows dirty reads; Read Committed prevents dirty reads; Repeatable Read prevents non-repeatable reads (and in Postgres/MySQL InnoDB mostly phantoms too); Serializable prevents all…
-
Most asked How do database indexes work and when do they help or hurt?
Most indexes are B-trees that keep column values sorted with pointers to rows, turning full-table scans into logarithmic lookups for equality, range and ORDER BY queries. They cost extra storage and…
-
How does database replication work, and what is replication lag?
A primary streams its changes (WAL/binlog) to replicas, which apply them to serve reads or take over on failure. With asynchronous replication, replicas trail the primary by some delay (lag), so…
-
How do you scale a relational database?
In order of effort: optimize queries and indexes, add caching, scale vertically, add read replicas for read traffic, use connection pooling, partition large tables, move workloads (analytics,…
-
How does the CAP theorem apply to databases?
During a network partition, a distributed database must choose between consistency (reject or block requests to avoid divergent data) and availability (keep serving, risking stale or conflicting…