System Design
How to Choose a Database in a System Design Interview
Pick the wrong database in an interview and everything downstream wobbles. After years of choosing databases for systems that ingest billions of events a day, here's the framework I actually use - and how to apply it under interview pressure.
In a system design interview, the database choice is one of the most consequential decisions you'll make - and one of the most revealing. Choose well and the rest of your design has solid ground to stand on. Choose poorly, or worse, choose without being able to say why, and a sharp interviewer will pull on that thread until the whole design unravels. I've chosen databases for systems handling billions of events a day, and I've also sat across the table watching candidates freeze on "so, what database would you use here?"
The good news: there's a framework, and it's not complicated. It's a small set of questions you ask about the data and the workload, and the answers point you to the right kind of database. Here's the framework I actually use, adapted for the pressure of a 45-minute interview.
The mistake to avoid first
Before the framework, the trap. The weakest answer to "what database would you use" is naming a specific product immediately - "I'd use Postgres" or "I'd use MongoDB" - with no reasoning behind it. It signals you're pattern-matching to something familiar rather than reasoning about the problem in front of you. The second-weakest answer is "it depends," and then stopping. Of course it depends - the interviewer wants to know on what, and to watch you reason through it.
The strong answer reasons from the requirements to a category of database first, then optionally names an example. So the framework isn't about memorizing which database to use for which app - it's about asking the right questions about your data and letting the answers guide you.
The questions that actually decide it
Here are the questions I ask, roughly in order of how much they tend to matter.
1. What's the access pattern?
This is the most important question, and the one candidates most often skip. How will the data be read and written? Specifically:
- Read-heavy or write-heavy? A system dominated by reads (most apps) has different needs than one dominated by writes (event ingestion, logging, metrics).
- What do the queries look like? Simple key lookups ("get user 123")? Or complex queries with filtering, joins, and aggregation ("all orders over 00 from customers in this region last month")? This single distinction does more to narrow the choice than almost anything else.
- What's the read/write ratio and volume? Are we talking thousands of operations per second, or millions?
The access pattern is the foundation. A database that's perfect for one access pattern can be terrible for another, so understanding how the data will actually be used comes before everything else - before structure, before consistency, before scale. Get the access pattern wrong and every later decision is built on sand.
2. What's the data's structure?
How structured and related is the data?
- Highly structured and relational - entities with clear relationships, where you need to query across those relationships (users have orders, orders have items)? That points toward a relational (SQL) database, which is built for exactly this.
- Flexible, varied, or schema-light - documents whose shape varies, or data where you don't need rich relationships? That opens the door to NoSQL options designed for flexibility.
3. What are the consistency requirements?
How critical is it that every read sees the latest write, immediately?
- Strong consistency required - financial transactions, anything where stale or conflicting data causes real harm? You need a database that guarantees it, and you accept the trade-offs that come with it.
- Eventual consistency acceptable - social media likes, view counts, feeds, where being a moment out of date is fine? That relaxes the constraints and opens up options that scale more easily.
This is where the CAP theorem lurks: at scale, strong consistency trades against availability and partition tolerance, so naming your consistency requirement is naming a fundamental trade-off. (See the dedicated guide on consistency models.)
4. What's the scale, now and later?
How much data, and how fast is it growing?
- Moderate, manageable on one machine (or one machine plus replicas) - a single powerful relational database goes a very long way, further than people assume.
- Massive, beyond one machine - you need a database designed to scale horizontally across many machines, which is where many NoSQL systems shine, and where relational databases require more work (sharding) to scale writes.
graph TD
A[What database?] --> B{Complex queries,<br/>joins, relationships?}
B -->|Yes| C{Strong consistency<br/>critical?}
B -->|No, simple lookups| D{Massive scale,<br/>flexible data?}
C -->|Yes| E[Relational / SQL]
C -->|Eventual OK| E
D -->|Yes| F[NoSQL<br/>key-value / document / wide-column]
D -->|Moderate| E
This decision tree shows how to narrow the database choice. Start by asking whether you need complex queries, joins, and relationships. If yes, a relational SQL database is usually right, especially if strong consistency matters. If you only need simple lookups, ask whether you have massive scale and flexible data - if so, a NoSQL database such as key-value, document, or wide-column fits; if the scale is moderate, a relational database still works well.
Mapping answers to database types
Once you've answered those questions, the category usually becomes clear. The main types, and when each fits:
- Relational (SQL) - structured, related data; complex queries and joins; strong consistency. The default for most applications, and far more scalable than its reputation suggests. When in doubt and the data is relational, this is rarely a wrong answer.
- Key-value store - simple, fast lookups by key; very high scale; no complex queries needed. Excellent for caching, sessions, and simple high-throughput lookups.
- Document database - flexible, semi-structured data (documents); queries within documents; easier horizontal scaling than relational. Good when the data is naturally document-shaped and the schema varies.
- Wide-column store - massive scale, high write throughput, queries by key with some flexibility. Built for huge volumes of data across many machines.
- Specialized stores - when the access pattern is specialized: a search index for text search, a time-series database for metrics, a graph database for heavily connected data. The signal that you need one of these is an access pattern that the general-purpose databases handle awkwardly - if you find yourself fighting your relational database to do full-text search or to traverse a deep graph of relationships, that's the cue that a specialized store built for exactly that pattern will serve you far better.
Tip: Here's something experience taught me that interviews rarely acknowledge: a well-run relational database handles far more than people expect. I've seen candidates jump to exotic NoSQL systems for scale they'll never reach, when a relational database with proper indexing, caching, and read replicas would serve them beautifully and keep the powerful querying they'll miss once it's gone. "Use a relational database, and scale it with caching and replicas" is a strong, defensible answer for a huge range of systems. Reach for NoSQL when you have a specific reason the relational model doesn't fit - massive write scale, genuinely flexible data, or an access pattern relational databases handle poorly - not because NoSQL sounds more impressive.
A worked example: applying the framework
Let me run the framework on a concrete prompt. Suppose the interviewer says "design the backend for an e-commerce store." When the database question comes, I don't name a product - I reason through the questions.
Access pattern: read-heavy (people browse far more than they buy), with a mix of simple lookups (show this product) and complex queries (orders for a customer, products in a category, sales reports). Structure: highly relational - customers, orders, order items, products, all with clear relationships I'll query across. Consistency: the order and payment data needs strong consistency (you can't have an order half-placed or wrong inventory), while the product catalog tolerates slight staleness. Scale: substantial but not extreme - well within what a relational database plus caching and replicas handles.
So I commit: "A relational database for the core data - customers, orders, products - because the data is highly relational, I need joins and complex queries, and the order/payment path needs strong consistency. Since it's read-heavy, I'll add a cache for hot reads like the product catalog and read replicas to spread query load. If product search becomes important, I'd add a dedicated search index for that specifically."
Notice the shape: reason through access pattern, structure, consistency, and scale; commit to a category with justification; add supporting stores (cache, search) for specific needs. That's a complete, defensible decision - and I never named a specific product.
Common systems and their typical database fit
To build intuition, here's how the framework tends to resolve for common system types:
- E-commerce / transactional apps → relational (structured, related, needs consistency and transactions), plus caching.
- Social feed / activity stream → often a mix: relational or NoSQL for core data, with high-volume feed data in a store optimized for it, accepting eventual consistency.
- Caching / sessions → key-value store (simple, fast lookups by key).
- Content/catalog with varied fields → document database (flexible schema fits varied content).
- Massive event/log/metrics ingestion → wide-column or time-series store (huge write volume, queries by key/time), not a single relational database.
- Search → a dedicated search index, regardless of the primary database.
- Heavily connected data (social graph, recommendations) → a graph database for the connected parts.
These aren't rules to memorize - they're what the framework produces when applied to each pattern. Internalize the reasoning, and you can derive these (and handle the systems not on this list) yourself.
The follow-ups interviewers will ask
Once you've chosen, a good interviewer probes - and being ready is part of answering well:
- "How does this scale?" Be ready to say how your choice scales - for relational, caching, read replicas, and eventually sharding; for NoSQL, the horizontal scaling built in. Don't pick a database you can't explain scaling for.
- "What about consistency here?" Expect to defend your consistency decision, especially eventual consistency - explain why it's acceptable for that data (fine for a like count to be briefly stale; not fine for an account balance).
- "Why not [the other option]?" Be ready to explain why you didn't choose NoSQL (or SQL). The honest answer is usually fit - "the data is relational and we need joins and transactions" or "the write volume exceeds what one relational database handles well."
- "What's the schema / data model?" Sometimes they'll want you to sketch the tables or document structure. Modeling the data concretely confirms your choice actually fits it.
Handling these follow-ups confidently turns a database choice from a single answer into a demonstration of understanding. The choice itself matters less than your ability to defend it.
A word on not over-engineering
One final piece of judgment experience teaches: there's a temptation to reach for complex, exotic database setups to look sophisticated - polyglot architectures with five data stores for a system with modest needs. Resist it. The strongest engineers match the solution's complexity to the actual requirements. If a single relational database with a cache serves the system well, that is the sophisticated answer, because it's simplest to build, operate, and reason about. Adding a wide-column store and a graph database and three caches to a system that doesn't need them isn't impressive - it's over-engineering, and a good interviewer sees through it. Choose the simplest set of databases that genuinely meets the requirements, and add complexity only where a specific need demands it.
How to deliver it in the interview
Knowing the framework is half the battle; using it well under pressure is the other half. The move that scores: think out loud through the questions, then commit. Something like: "This is read-heavy with complex queries across related data, and we need strong consistency for the financial parts, so I'll use a relational database - and since it's read-heavy, I'll scale reads with caching and replicas."
Notice what that does. It states the access pattern, the structure, and the consistency need; it reasons to a category; and it commits to a choice with justification. That's exactly what the interviewer wants to see - not the "right" database (there's rarely one right answer), but the reasoning connecting requirements to choice.
And don't be afraid to use different databases for different parts of the system. A real system often uses a relational database for its core transactional data, a cache for hot reads, a search index for search, and object storage for files. Recognizing that you can pick the right tool for each part - rather than forcing everything into one database - is a senior-level signal.
Interview: When I evaluate a database choice, I'm barely listening for which database. I'm listening for whether you reasoned from the access pattern, the data structure, the consistency needs, and the scale - and committed to a choice you can defend. A candidate who says "I'll use Postgres" and can't say why is weaker than one who says "I'll use a relational database because the data is relational, we need joins, and consistency matters here, and I'll scale reads with caching." Reason to the category, justify it, and you've answered the question well - even if I'd have chosen differently. The choice is rarely unique; the reasoning is what's being assessed.
The bottom line
Choosing a database in an interview isn't about memorizing which product fits which app - it's about asking the right questions and reasoning to a category. The questions that decide it: what's the access pattern (read/write balance, simple lookups versus complex queries), how structured and related is the data, how strong must consistency be, and what's the scale now and later. Those answers point you to relational, key-value, document, wide-column, or a specialized store. And a quiet truth from running real systems: a well-run relational database with caching and replicas serves a far wider range of problems than people assume - reach for NoSQL when you have a specific reason, not for impressiveness.
Reason out loud from requirements to choice, commit with justification, and use different tools for different parts where it helps. Do that, and the database question becomes one of the strongest parts of your design. We work through database selection and data modeling across System Design Fundamentals.
Go deeper
- Designing Data-Intensive Applications - the definitive reference for reasoning about databases and data systems.
- The System Design Primer - database types and when to use each.
- NoSQL (Wikipedia) - the non-relational families and their trade-offs.
- Amazon Builders' Library - how databases are chosen and run in production.