DBMS Interview Questions and Answers

Transactions, indexes, normalisation, concurrency and query planning.

Practise 10 random 2 peer-reviewed questions
DBMS Interview Syllabus & Preparation Strategy

Whether you are preparing for entry-level DBMS interview questions for freshers or senior software engineer interview questions addressing concurrency, scalability, and system architecture, this track provides peer-reviewed model answers with syntax walkthroughs, edge cases, and practical interview tips.

1 Explain two-phase commit and its drawbacks. Hard

Two-phase commit, 2PC, is an atomic commit protocol for transactions spanning multiple databases or resource managers.

Phase one, prepare: the coordinator asks every participant to prepare. Each does the work, writes it to a durable log, acquires locks and votes yes or no.

Phase two, commit: if all voted yes, the coordinator logs the decision and tells everyone to commit; if any voted no, it tells everyone to roll back.

coordinator -> prepare -> all vote yes
            -> commit  -> all commit

Atomicity holds even across a crash, because a participant that voted yes can recover from its log and follow the coordinator's decision. The main problems are blocking: if the coordinator fails after prepare, participants hold locks and wait for it to recover. It is also synchronous and slow.

Consequently, modern distributed systems often prefer consensus-based replication or sagas, which trade isolation for availability and use compensating actions instead of a global atomic commit.

2 How would you scale a relational database as traffic grows? Hard

Scaling relational databases follows a progression, because a single node eventually hits CPU, memory or I/O limits.

  1. Optimise first: fix queries, add indexes, tune the buffer pool and connection pooling, and archive old data.
  2. Read scaling: add replicas and route reads to them, accepting replication lag. Use a cache such as Redis for hot data.
  3. Vertical scaling: more RAM and faster disks, such as NVMe, often beat complex sharding and buy time.
  4. Partition large tables by range or hash to keep working sets manageable.
  5. Shard: split data across nodes by a shard key so writes scale. This makes cross-shard joins, transactions and unique constraints hard.
app -> primary (writes)
         | replication
         v
     replicas (reads)   + cache

Choose the shard key for even distribution and locality, and plan resharding and rebalancing. Some workloads are better served by a NoSQL or NewSQL store, or by CQRS with separate read and write models.

Frequently Asked Questions About DBMS Interviews

What do hiring managers evaluate in DBMS technical rounds?

Technical interviewers look for foundational fluency, idiomatic syntax, clarity when communicating complex logic, and awareness of performance trade-offs (e.g. memory footprint, render performance, and network latency) in production environments.

What are the best interview tips for practicing DBMS questions?

Use active recall: summarize each answer in your own words before revealing the model solution. Focus on explaining why a certain approach is chosen rather than just memorizing code syntax.