Database Selection and Trade-offs Questions
Choosing the right database and data platform for a workload: relational versus NoSQL versus specialized stores, managed versus self-hosted, and matching technology to consistency, scale, cost, and query or access-pattern needs. Covers OLTP versus OLAP and transactional-versus-analytical workload splits, polyglot persistence across multiple data stores, structuring an ambiguous selection prompt, naming trade-offs, and defending a recommendation to stakeholders.
You lead a cross-functional committee to choose the company's next data platform. Describe the process you'll run: committee membership, evaluation criteria (technical and non-technical), scoring model, PoC plan, decision gates, and how you will communicate and roll out the final decision to engineering and business stakeholders.
Sample Answer
Direct answer
Run a staged process: a small cross-functional committee agrees weighted evaluation criteria before looking at any vendor, narrows a full landscape to two or three finalists on desk research alone, runs a time-boxed proof-of-concept (PoC) against only those finalists with success metrics fixed in advance, scores independently before discussing as a group, and only then decides and rolls out in phases. The single thing that makes this defensible later, versus looking reverse-engineered from whichever answer leadership already wanted, is publishing the criteria and their weights before anyone sees a PoC result.
Structured elaboration
Committee membership
| Seat | What they represent |
|---|---|
| Chair (often an architect or senior engineer) | Runs the process, resolves disagreements, has no extra vote |
| Engineering lead for the consuming team | The people who will build against this platform day to day |
| Operations or database reliability representative | Who will be paged when it breaks |
| Security and compliance representative | Whether the option is legally and contractually usable |
| Finance or procurement representative | True cost, including support and egress, not just a list price |
| A business stakeholder who represents actual users of the workload | Keeps the process grounded in a real need, not a technology preference |
Evaluation criteria
Technical: performance under a representative workload, operational fit with existing team skills, scalability headroom, ecosystem and tooling maturity, integration surface with existing systems. Non-technical: total cost of ownership, vendor viability and financial stability, contract and support terms, compliance certifications, migration and exit cost.
Scoring model
A weighted rubric, the same shape used for a single-engineer trade-off decision, but scored by each committee member independently first, then discussed only to resolve disagreements, not to reach discussion-first consensus. Independent-then-discuss prevents the loudest or most senior voice in the room from anchoring everyone else's score before they've formed their own.
PoC plan
Cap the PoC at two to three finalists; running a full PoC against a wide field costs more engineering time than the decision merits and delays it. Define success metrics before the PoC starts (a specific query pattern must meet a stated latency target, a specific failure must be recoverable within a stated time), run against a representative slice of real or realistic data and load, and time-box it to a fixed number of weeks regardless of how it's going.
Decision gates
Gate 1: narrow the full landscape to finalists using desk research and vendor calls. Gate 2: PoC results reviewed strictly against the pre-committed success metrics. Gate 3: final committee scoring and sign-off. Gate 4: rollout plan reviewed and approved before implementation starts.
Communication and rollout
Publish the decision as a document (effectively an ADR at the organization level) to engineering and business stakeholders, including the criteria, weights, and PoC results, not just the conclusion. Hold a Q&A or office-hours period before implementation begins. Roll out in phases, starting with a low-risk workload or team, so a mistake is cheap to catch and reverse.
Worked example
A committee tasked with choosing the company's next cloud data warehouse, replacing an aging on-prem analytics database, shortlists two cloud columnar warehouses after desk research, then runs a PoC loading a representative slice of the company's actual query workload against both. A simplified scoring pass after the PoC (weights out of 100, scores 1 to 5):
| Criterion | Weight | Candidate A | Candidate B |
|---|---|---|---|
| Query performance on our workload | 25 | 4 | 5 |
| Cost at our data volume | 25 | 4 | 3 |
| Team's existing SQL skill transfer | 15 | 5 | 4 |
| Compliance certifications | 20 | 5 | 5 |
| Migration effort from the current system | 15 | 3 | 4 |
Candidate A: (25x4)+(25x4)+(15x5)+(20x5)+(15x3) = 100+100+75+100+45 = 420. Candidate B: (25x5)+(25x3)+(15x4)+(20x5)+(15x4) = 125+75+60+100+60 = 420. A genuine tie forces the committee back to its stated priorities rather than a coin flip, in this case, deciding in advance that cost matters more than raw performance at the company's actual query volume would break the tie toward Candidate A.
Trade-offs & pitfalls
Committees can drift into consensus-by-exhaustion, where the option nobody strongly objects to wins rather than the option that scored best, unless the chair forces every disagreement to be argued against the written criteria rather than settled by seniority. Running PoCs against too many finalists spreads engineering time thin and delays the whole decision without proportionally improving it. A rollout plan is frequently the section real committees skip entirely, but a decision without a phased rollout and a rollback plan isn't actually finished, it's only chosen.
You're designing the storage layer for a new e-commerce product catalog and order service. For each of these two use cases, justify whether you'd choose a relational database (e.g., PostgreSQL), a document store (e.g., MongoDB), or a key-value store. Include considerations such as schema flexibility, transactional guarantees, query patterns (joins, filters), indexing, and expected operational complexity.
Sample Answer
Direct answer
For the CATALOG, prefer a document store: flexible, evolving product attributes with no cross-entity transaction requirement. For the ORDER SERVICE, prefer a relational database: placing an order genuinely needs multi-row atomicity (create the order, decrement inventory, write a payment record, all-or-nothing), exactly what ACID (atomicity, consistency, isolation, durability) transactions across related tables are for. A key-value store is not a strong PRIMARY-store fit for either use case; it is a fine cache in front of either, but neither entity is a pure opaque-blob-by-id access pattern.
Structured elaboration
Product catalog: document store. Schema flexibility: new product categories bring new attribute sets constantly (a shirt has size and color, a laptop has RAM and storage) without forcing every product into one rigid table shape or a sparse, mostly-null relational schema. Query patterns: filter and browse by nested attributes, not joins across many other business entities. Transactional guarantees: catalog writes are single-document updates (change this product's price), rarely needing multi-entity atomicity. Indexing: multikey and compound indexes on nested fields, as with a session-versus-catalog comparison. Operational complexity: moderate, mostly around index and mapping management as attribute sets evolve.
Order service: relational. Transactional guarantees are the deciding factor: placing an order typically means, in one atomic unit, inserting the order row, decrementing stock in the inventory table, and writing a payment or ledger entry, and if any step fails the whole thing must roll back, because a half-completed order (charged but not recorded, or recorded but inventory not decremented) is a business-critical bug, not a tolerable edge case. Query patterns: relational joins across orders, order line items, inventory, payments, and customers (for reporting, refunds, and support lookups) are exactly what SQL and foreign keys are built for. Schema flexibility: an order's shape is comparatively STABLE compared to a catalog's attribute set, so relational rigidity is a feature here, not a cost. Indexing: standard B-tree indexes on order id, customer id, status, and created-at timestamp cover the access patterns. Operational complexity: lower for this shape of data; the main cost is planning for checkout-peak write volume (connection pooling, read replicas for reporting so they don't compete with the transactional write path).
Why not key-value for either. A KV store doesn't index into structure, ruling out catalog facet browsing without a second system, and doesn't offer multi-key transactions across DIFFERENT keys the way a relational database does across tables, ruling out the order's atomic multi-write requirement. Its honest place in this architecture is as a CACHE in front of either store (hot product pages, an in-flight order's status for fast polling), never as the system of record for either.
Worked example
BEGIN;
INSERT INTO orders(id, customer_id, status) VALUES (:order_id, :customer_id, 'placed');
UPDATE inventory
SET stock = stock - :qty
WHERE sku = :sku AND stock >= :qty;
INSERT INTO payments(order_id, amount, status) VALUES (:order_id, :amount, 'captured');
COMMIT;
The inventory UPDATE's WHERE stock >= :qty guard prevents overselling under concurrent orders: the row lock the UPDATE takes serializes concurrent decrements against the same SKU, so a second, simultaneous order for the last unit either succeeds against updated stock or fails the guard and rolls back, never both succeeding against the same unit. The document-store equivalent needs either a multi-document transaction (supported by MongoDB since version 4.0, but positioned as an exception path, not the default access pattern, and it adds latency) or application-level compensating logic (a saga, a sequence of local transactions with defined undo steps for partial failure), meaningfully more code and more failure modes for the same guarantee relational gives for free.
Trade-offs & pitfalls
Teams sometimes pick ONE database for the whole application "for simplicity" and either fight a document store to get order transactions working, or fight rigid relational tables (constant migrations, or a sprawl of nullable columns) to hold the evolving catalog. Using two purpose-fit stores costs one extra piece of operational surface area but avoids both failure modes. The answer doesn't actually turn on the specific product names chosen (Postgres or any equivalent relational engine, MongoDB or any equivalent document store); it turns on which of the two access-pattern shapes, flexible-attribute browsing versus multi-entity atomic transaction, the entity in question actually has.
Design an HTAP architecture that allows transactional workloads to run with low latency while supporting real-time analytics. Compare using TiDB / CockroachDB / SingleStore vs using transactional DB with a near-real-time analytics replica (read-replica or materialized change pipeline). Discuss consistency, cost, and operational complexity.
Sample Answer
Direct answer
Given an OLTP (online transaction processing: a workload of many small, fast reads and writes, like inserting one order) primary already straining under mixed transactional and analytic load, the default move is not to reach for a purpose-built HTAP (hybrid transactional/analytical processing: a single database built to serve both transactional writes and analytical scans well) database (TiDB, CockroachDB, SingleStore); that's a bigger migration and operational commitment than most situations call for. Get the analytic load off the primary first, using whichever of three offload patterns fits the freshness requirement, and only adopt a dedicated HTAP engine when none of those can meet it at acceptable operational cost, most often when a single request genuinely needs a transactionally-consistent read and a large aggregation together.
Structured elaboration
Three offload options, analyzed separately (not one bundled choice)
| Option | Data freshness | Resource isolation | Cost | Implementation complexity |
|---|---|---|---|---|
| Read replica (an async streaming copy of the primary, queried directly) | Seconds under normal load, but lag grows under write bursts or heavy analytic scans since replay still competes with reads for the same cache and I/O internals | Partial: it's a separate instance, but a big scan can still starve the replica's own apply thread, widening lag further | Lowest to stand up, since most managed relational services support replicas natively with little new tooling | Lowest: usually a checkbox in the managed console, the complexity is in monitoring lag, not building the pipeline |
| CDC to a warehouse (a change-data-capture pipeline streaming committed row changes into a columnar store) | Typically tens of seconds to a few minutes, bounded by pipeline lag rather than replica replay contention | Strong: the warehouse is a fully separate engine with its own resources | Moderate: pipeline infrastructure plus warehouse compute, but each scales independently | Moderate: schema mapping, handling schema drift, and reconciling the two copies periodically |
| Lambda or kappa streaming architecture (an event stream feeding both a fast approximate layer and a batch-corrected layer, or a single reprocessable stream) | Can be sub-second for the speculative layer, with the batch layer correcting it later | Strongest: fully decoupled compute for ingestion, speculative serving, and batch correction | Highest: multiple processing layers (lambda) or full-stream reprocessing cost (kappa) | Highest: two code paths to keep consistent (lambda) or a genuinely different mental model (kappa); this is the right tool only if you already need general-purpose streaming beyond this one reporting problem |
Purpose-built HTAP engines, named honestly
The question groups TiDB, CockroachDB, and SingleStore together, but they are not equivalent on analytics, and current vendor documentation says so directly:
- TiDB pairs a row-oriented engine (TiKV) with a columnar replica (TiFlash) that replicates data in real time specifically to isolate analytical scans from the transactional path. This is a genuine HTAP design.
- SingleStore unifies row and columnar storage in one engine (its Universal Storage layer), letting the same table serve fast point operations and large scans without a separate replica. Also a genuine HTAP design.
- CockroachDB is a distributed, strongly-consistent, Postgres-wire-compatible SQL database, and a strong option for horizontally-scaled OLTP. Its own current documentation states it is not yet suitable for heavy analytics or OLAP (online analytical processing: workloads dominated by large scans and aggregations, not small transactional writes) workloads. Grouping it with the other two as an HTAP option overstates what it is built for today; it solves the "scale my transactional writes across nodes" problem, not the "run heavy aggregations without hurting my writes" problem this question is actually about.
Consistency, cost, and operational complexity, compared directly
Consistency. A read replica and a CDC-to-warehouse pipeline are both eventually consistent by construction: the analytic side lags the primary by a bounded but nonzero amount, which is fine for a dashboard and wrong for a decision that must see a just-committed write. A lambda or kappa stream can narrow that gap to sub-second for its speculative layer, but the speculative answer is provisional until the batch layer corrects it, which is a different kind of eventual consistency, not none. TiDB and SingleStore, by contrast, keep the analytic-capable path inside the same transactionally consistent system as the writes (TiFlash replicates from TiKV with a bounded, typically sub-second, delta, and SingleStore's unified storage reads the same committed rows a transactional query would), so they are the only options on this list where an analytic read can be given the same consistency guarantee as a transactional one, at the cost of everything below.
Cost. The three offload options each add infrastructure that scales somewhat independently of the primary (a replica instance, a warehouse's compute, or a streaming platform's brokers and processing layer), which is usually cheaper at moderate scale than re-platforming onto a distributed SQL engine, since the primary itself keeps its existing footprint. A purpose-built HTAP engine instead replaces the primary, so its cost has to be compared against the full cost of the current primary plus every offload piece it would remove, not against the offload pipeline alone.
Operational complexity. The offload options add a pipeline to operate (replication lag monitoring, CDC schema-drift handling, or a streaming platform), but the primary itself, the part most of the team already knows how to run, stays untouched. A purpose-built HTAP engine removes the pipeline but replaces the whole primary with a system that has its own distributed-systems failure modes (node loss, rebalancing, cross-region consensus) that most teams have not yet built operational muscle for, which is real complexity even when the architecture diagram looks simpler.
Worked example
Assume the OLTP primary currently handles about 8,000 writes per second, and a nightly reporting job has grown long enough to run into business hours, pushing write p99 latency (the 99th-percentile latency: 99% of writes finish faster than this number, so it captures the slow tail rather than the typical case) from roughly 40 ms to over 300 ms while it runs (an illustrative scenario, not a measured benchmark). First move: a read replica dedicated to the reporting job, with a statement timeout so a runaway query can't further degrade replication apply. If lag during the batch window is still unacceptable because the reporting queries are large table scans that saturate the replica's own I/O, move to CDC into a columnar warehouse, which removes analytic I/O from any row-oriented engine entirely. Only if the business then adds a requirement like "score this transaction for fraud using both the row just written and a rolling aggregate, within the same request, before it's approved" is there a genuine argument for TiDB or SingleStore: that's a single request needing strongly consistent point access and analytical aggregation together, which none of the three offload options can give you, since they are all, by design, a step removed from the primary.
Trade-offs & pitfalls
HTAP engines trade a smaller pool of operational expertise and newer failure modes for solving a problem the offload options structurally cannot. Each offload option has its own failure mode: read replicas silently grow stale under exactly the load spikes you're trying to protect against, so lag needs active alerting, not a one-time setup; CDC pipelines can drift on schema changes and need periodic reconciliation, not just a "pipeline is running" health check; lambda and kappa architectures are frequently adopted for one reporting problem and then become a permanent, expensive platform commitment because reverting is harder than the original decision to adopt one.
You need sub-10ms read latency at 100k QPS for personalization lookups while also supporting daily petabyte-scale analytics. Which database(s) would you choose for the low-latency store (Redis, Cassandra, DynamoDB, RocksDB-based stores) and how would you integrate it with your analytics stack? Discuss consistency, replication, warming strategies, and cost implications.
Sample Answer
Direct answer
For sub-10-millisecond reads at 100,000 queries per second on personalization lookups, use an in-memory store such as Redis, or a managed equivalent, as a purpose-built low-latency layer in front of the system of record. In-memory access is the only one of the four named options, Redis, Cassandra, DynamoDB, and RocksDB-based stores, that reliably clears a single-digit-millisecond bar at that request rate without careful additional tuning, and it should stay fully decoupled from the separate daily petabyte-scale analytics pipeline, which runs entirely off an independent, asynchronously fed path rather than ever touching the low-latency store directly.
Structured elaboration
Redis. An in-memory data structure store; read latency is dominated by the network round trip plus an in-memory lookup, commonly sub-millisecond for the lookup itself on modern hardware, an architectural characteristic rather than a specific measured run here, leaving ample headroom under a 10 millisecond budget even after network and serialization overhead. Best fit when the personalization payload is small enough to fit in memory across the cluster and can tolerate Redis's default asynchronous replication, where a replica acknowledgment is not required before a write is considered done, so a primary failure can lose the last few writes, acceptable for a recomputable, cache-shaped personalization feature.
DynamoDB, with its in-memory accelerator cache, DAX (DynamoDB Accelerator). Base DynamoDB read latency is typically single-digit milliseconds even without the accelerator, and the accelerator adds a microsecond-latency cache layer in front for the hottest keys. A reasonable choice when the team wants DynamoDB's durability and operational model but needs to shave the tail latency the accelerator specifically addresses, at its added cost and cache-invalidation complexity.
Cassandra. Tunable per-query consistency lets a team trade freshness for speed on reads, and it scales write-heavy workloads well, but its read latency profile, even at the fastest consistency level, is typically higher than a pure in-memory store, since it still touches disk-backed storage files unless the working set is fully cached internally. Viable, but a heavier operational lift to consistently clear a 10 millisecond bar than an in-memory-first option.
RocksDB-based stores. RocksDB itself is an embedded key-value engine, not a standalone distributed service, so "RocksDB-based" in a distributed context usually means either co-locating a RocksDB instance per application host, the lowest possible latency since there is no network hop at all, but the team now owns data distribution and replication itself, or a managed distributed store built on top of RocksDB. Legitimate when the specific goal is eliminating the network hop entirely, at the cost of building a custom replication and consistency story.
Given the stated bar, sub-10 milliseconds at 100,000 queries per second, with no explicit need to eliminate the network hop entirely or to keep DynamoDB's specific durability model, Redis is the most directly fitting default; DAX-backed DynamoDB is the next best choice if the team is already standardized on DynamoDB as the system of record and wants one fewer new technology to operate.
Replication and warming. A Redis cluster shards data across primaries, each with asynchronous replicas for failover. An easy-to-miss operational detail is cache warming: a freshly promoted replica, or a newly added shard, starts with only whatever it received as a normal replica, not a full copy of the working set built for that exact moment. A cold cache under 100,000 queries per second means the backing store that feeds Redis suddenly absorbs close to the full request rate directly, at a scale it was never sized for. Mitigate with a warm standby kept populated through the same write path as the primary, not one that merely catches up after promotion, or a controlled, gradual traffic ramp after any topology change.
Integrating with the analytics stack. The low-latency store should never be queried directly by the daily petabyte-scale analytics job. An aggregate scan against an in-memory cache is both slow relative to a columnar store's design and risks evicting the hot working set serving live traffic. Instead, personalization writes should flow, through the same event stream or change-data-capture mechanism feeding other parts of the architecture, into one durable, append-oriented log that also feeds the analytics warehouse, so the low-latency store and the analytics pipeline are two independent consumers of a single write path, never two systems that talk to each other.
Worked example
At 100,000 queries per second with a stated 2 kilobyte average personalization payload, sustained read bandwidth is 100,000 x 2 / 1024 ~= 195.3 megabytes per second before replica fan-out. If a single Redis primary shard sustains on the order of 100,000 to 200,000 simple read operations per second, a stated, architecture-level assumption rather than a benchmark claim, the raw throughput target is coverable by a small number of shards, though real deployments provision more shards than the bare minimum specifically for replica-based read fan-out and headroom against a shard failure, not merely to clear the raw queries-per-second number. At this volume, 100,000 queries per second sustained works out to roughly 259 billion requests per month, per-request pricing models become the dominant cost driver, the concrete economic argument for a node-hour-billed in-memory tier over a purely per-request-billed managed store for this specific access pattern.
Trade-offs and pitfalls
A pitfall is sizing the in-memory tier only for raw throughput, as the bare arithmetic above might suggest, and skipping replica-based failover headroom. A single-shard, single-node design has no room for a node failure without an availability gap, precisely when the system is under its heaviest load.
A second pitfall is letting the analytics pipeline read the personalization store directly because it is already there. That couples an availability-critical low-latency path to an unrelated, much heavier batch workload's failure modes and resource contention.
What would flip the recommendation: if the personalization payload is too large to fit affordably in memory across the fleet, a fundamentally different sizing problem than queries per second, or if the durability bar rules out Redis's default asynchronous replication, some data loss on primary failure unacceptable even for a recomputable feature, DAX-backed DynamoDB's stronger default durability model becomes the better fit despite its added architectural piece.
What criteria would you use to decide between a managed database service (e.g., AWS RDS/Aurora, DynamoDB, MongoDB Atlas) and self-managed instances? List operational, cost, scaling, and team-skill considerations and give one example where self-managed is preferable.
Sample Answer
Direct answer
Default to a managed database service (for example Amazon RDS or Aurora, DynamoDB, or MongoDB Atlas) unless there is a specific, named reason to self-host, because a managed offering removes an entire category of operational risk (patching, failover (automatically promoting a healthy replica to take over when the primary database fails), backup verification, version upgrades) that otherwise falls on the team's on-call rotation. The cases for self-managing are real but narrow, and should be named explicitly rather than assumed.
Structured elaboration
| Criterion | Managed | Self-managed |
|---|---|---|
| Operational burden | Provider owns patching, failover, backup verification, version upgrades | Your team owns all of it, including the middle-of-the-night page |
| Cost model | A premium per compute/storage unit, but it bundles operational labor into the price | Lower raw infrastructure cost, but the fully-loaded cost of the engineering time to run it well is easy to undercount |
| Scaling | Often push-button vertical resize; sometimes built-in read scaling (for example Aurora read replicas) or serverless auto-scaling capacity | You build and own the scaling automation yourself |
| Team skill | Lowers the bar; a generalist backend team can run it | Needs a specialist, or a team willing to build that specialism and deeply understand the specific engine's failure modes, not just its query language |
| Control / customization | Bounded by what the managed product exposes | Full control: custom extensions, operating-system-level tuning, non-standard versions, unusual network topology |
| Compliance / data residency | Depends on the specific managed offering's supported regions and certifications | You control this directly, at the cost of owning the compliance work yourself |
One example where self-managed is preferable: a regulated environment with a specific data-residency or network-isolation requirement (for example an air-gapped network) that no managed provider's available regions or deployment topology satisfies, or a team that depends on a specific database extension, fork, or build flag that isn't on the managed service's supported extension list. In both cases, the constraint isn't "we could save money," it's "the managed product literally cannot do the thing we need," which is a fundamentally different, much stronger justification than a cost argument.
Worked example
Rather than inventing a specific dollar figure I can't verify for either path, the honest way to reason about the cost axis is this: the fully-loaded cost of one senior engineer's on-call time is typically a substantial multiple of the price premium a managed service charges over raw compute, for a small-to-mid-size production database. That's why "we'll save money by self-hosting" deserves real skepticism as a stated justification unless the team can name concrete, recurring engineering hours it expects to save, not just point at the sticker-price difference between the managed tier and raw infrastructure cost.
Trade-offs & pitfalls
The biggest pitfall is treating "managed versus self-managed" as a one-time, permanent decision. Teams that grow real database specialization sometimes migrate FROM managed TO self-managed later, specifically to unlock a feature or a cost structure the managed tier doesn't offer at their scale, and that migration itself carries genuine risk (cutover planning, data-migration validation) that needs to be weighed honestly against simply staying managed and working around the limitation.
Unlock Full Question Bank
Get access to all Database Selection and Trade-offs interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.