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 What does ACID mean?
ACID describes transaction guarantees: Atomicity (all or nothing), Consistency (constraints hold before and after), Isolation (concurrent transactions don't see each other's partial work, to a…
-
Most asked What is the N+1 query problem and how do you fix it?
N+1 happens when code loads a list (1 query) and then lazily queries a relation for each item (N queries), multiplying round trips. Fix it with eager loading (JOIN or batched IN queries),…
-
Most asked What is connection pooling and how do you size a pool?
A pool keeps a set of open database connections that requests borrow and return, avoiding the cost of opening connections per request and capping concurrent load on the database.
-
What is normalization, and when should you denormalize?
Normalization organizes data to remove redundancy (1NF atomic values, 2NF no partial dependencies, 3NF no transitive dependencies), so each fact is stored once and updates stay consistent.…
-
What are partitioning and sharding, and what are their trade-offs?
Partitioning splits a large table into pieces within one database (by range, list or hash) for manageability and pruning; sharding distributes data across multiple database servers by a shard key to…
-
What is the transactional outbox pattern?
Write the business change and an 'event to publish' row in the same database transaction; a separate relay (poller or CDC like Debezium) reads the outbox table and publishes to the message broker,…
-
What are the pros and cons of using an ORM?
ORMs speed up development with object mapping, migrations, relationship loading and protection against SQL injection, but can hide inefficient queries (N+1, over-fetching), make complex queries…
-
What are the trade-offs of soft deletes?
Soft deletes (a deleted_at column) allow undo and auditing but require every query to filter deleted rows, complicate unique constraints and foreign keys, keep data that privacy laws may require you…
-
What is MVCC and how does it affect performance?
Multi-Version Concurrency Control keeps multiple versions of rows so readers see a consistent snapshot without blocking writers. In PostgreSQL, updates create new row versions; old versions are…
-
What is read-your-writes consistency and how do you provide it?
Read-your-writes guarantees that after a user writes data, their subsequent reads see that write, even if other users may see it later. Provide it by reading from the primary for a short window…
-
What are key database security practices?
Least-privilege accounts per service, no direct internet exposure, TLS in transit, encryption at rest, parameterized queries, secrets in a manager with rotation, auditing of privileged access, and…