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.
Your organization is concerned about vendor lock-in after adopting a managed cloud analytics service. Propose concrete strategies to minimize lock-in risk while benefiting from managed services: data export portability, use of open file formats, decoupling compute from storage, and operational processes to make migration feasible.
Sample Answer
Direct answer
Land data in an open, columnar file format in storage you control, not the vendor's proprietary internal representation; keep the storage layer decoupled from the query engine so a different engine could read the same files; automate a recurring, tested export rather than relying on a one-time "we could leave if we needed to" claim; and keep transformation logic in vendor-neutral tooling instead of the vendor's proprietary pipeline UI.
Structured elaboration
Open file formats
Land raw and curated data as Parquet (a columnar, compressed, self-describing file format nearly every analytics engine, including a future replacement, can read directly), optionally managed by an open table format like Apache Iceberg or Delta Lake (a metadata layer that tracks a table's schema, partitions, and file versions on top of the underlying Parquet files, so more than one engine can safely read and write the same table), rather than letting data live only inside a proprietary warehouse's internal storage representation.
Decoupling compute from storage
Keep those files in your own object storage bucket as the actual source of truth, and treat the managed analytics service as a compute engine that reads that storage, not a system that owns and internally encodes your data. If the files are portable, swapping which engine queries them becomes a compute-layer decision, not a full data migration.
Data export and portability discipline
Don't treat exportability as a one-time claim from the vendor evaluation document. Put a scheduled job in place that actually exports a representative slice of data on a real cadence and verifies it lands correctly in the open format, so "we could leave" is a tested, working capability rather than an assumption that turns out to be wrong exactly when you need it.
Operational processes
Keep the SQL that turns raw tables into curated ones in a vendor-neutral tool that compiles to standard SQL, rather than the vendor's low-code pipeline UI, and keep infrastructure-as-code definitions of the pipeline outside the vendor's console so its shape is documented and reproducible against a different engine. Track and periodically re-estimate the actual dollar and engineering-time cost of a hypothetical migration, an exit-cost line item revisited yearly, which turns lock-in from a vague fear into a number the organization can decide to accept or address.
Worked example
Raw ingested events land as Parquet files partitioned by date in an object storage bucket the organization owns. The managed cloud data warehouse is pointed at that bucket as external or staged tables (the warehouse queries the files where they already sit in your own storage, instead of copying them into its own internal storage first) rather than being the only place the data lives. Transformations are written as models in a vendor-neutral tool that compiles to portable SQL and are version-controlled outside the vendor's console. Once a quarter, an automated job spins up an alternate open-source query engine against the same Parquet files and runs a handful of the production queries, comparing results, which is the tested exit capability, not a claim on paper.
Trade-offs & pitfalls
None of this is free. Landing data in your own storage and keeping the pipeline vendor-neutral gives up some of the managed service's most convenient proprietary features, auto-optimized proprietary storage layouts, one-click pipeline UIs, and adds real engineering effort to build and maintain the portability tests. A team should invest in the full version of this only if a migration is a genuinely plausible future, not apply it reflexively to every vendor relationship regardless of actual switching risk. The most common pitfall is doing the open-format part, which is cheap and mostly automatic with modern warehouses, and skipping the periodic exit-test job, which requires real ongoing effort, leaving the organization with a false sense of portability that was never actually verified.
You are deciding between Postgres and MongoDB for a new service. As an EM, list concrete criteria you would use to choose one over the other: data model, transactional requirements, indexing/query patterns, scaling, backup/recovery, operational cost, and team skills. Give one brief example workload that favors each.
Sample Answer
Direct answer
As an engineering manager, this decision isn't purely technical: team skills and operational cost carry real weight alongside data-model fit. For a team that already knows relational modeling and SQL, default to PostgreSQL unless the data is genuinely document-shaped (deeply nested, schema varies per record) or the access pattern is dominated by simple key-based lookups at very large horizontal scale, in which case MongoDB's document model and native sharding are the better technical fit and worth the ramp-up cost.
Structured elaboration
| Criterion | PostgreSQL | MongoDB |
|---|---|---|
| Data model | Relational: tables, foreign keys, joins, plus a flexible JSONB column type for semi-structured fields when needed | Document: each record is a self-contained JSON-like document, a natural fit when related data is usually read and written together as one unit |
| Transactional requirements | Multi-row, multi-table ACID (atomicity, consistency, isolation, durability: a transaction either fully completes or has no effect at all, and finished data survives a crash) transactions as a mature, first-class feature | Supports multi-document ACID transactions too, but they are more expensive relative to its native single-document atomicity; the natural MongoDB design keeps most operations scoped to a single document in the first place |
| Indexing and query patterns | Mature query planner, joins, and complex ad hoc queries via SQL: strong for reporting-shaped reads | Indexes on document fields including nested ones, strong for lookups and aggregation-pipeline queries scoped to a collection, weaker for ad hoc cross-collection joins |
| Scaling | Scales vertically well, and horizontally via read replicas or partitioning for write scaling | Built-in horizontal sharding, splitting a collection's data across shards by a chosen key, as a native, well-trodden feature |
| Backup/recovery | Mature backup and point-in-time recovery tooling, especially on managed offerings | Equally mature on managed offerings; roughly a wash between the two |
| Operational cost | Large, low-cost-to-hire talent pool | Sharding and replica-set operations have their own learning curve and specialist hiring cost |
| Team skills | Near-zero ramp cost for a team that already writes SQL and thinks relationally | Lower ramp cost specifically for a team already comfortable with document modeling, or for junior engineers who find it more intuitive for a specific dataset, a legitimate input even though it isn't purely technical |
Worked example
Favors PostgreSQL: a subscription billing system, invoices, line items, payments, and customers that must never drift out of sync, an invoice total must always match the sum of its line items, enforced by foreign keys and a single transaction, where the business also regularly needs ad hoc relational reporting across customers, invoices, and payments.
Favors MongoDB: a product catalog where each category has a wildly different, evolving set of attributes, a laptop has RAM and CPU fields, a t-shirt has size and color fields, a new category ships next quarter with fields nobody has defined yet, read almost entirely as "fetch this one product's full detail." Forcing every category into a fixed relational schema means constant migrations or a sparse, mostly-null wide table, while a per-product document naturally holds exactly the fields that product has.
Trade-offs & pitfalls
The most common bad decision here isn't picking the wrong engine, it's picking on hype: choosing MongoDB because "it scales" for a team that will never approach a single well-tuned Postgres instance's ceiling, or choosing Postgres because it's the safe default for a workload that's genuinely document-shaped and will fight the relational model for years. As EM, weigh team skills honestly: a team's first production sharding incident is a real cost, and "we'll learn it" is a training-budget-and-timeline decision, not a footnote in the proposal.
Draft a concise one-page decision memo recommending database types for a mixed workload system supporting 1M daily users: product catalogs, user sessions, and analytics. Include constraints, a proposed hybrid architecture with component mapping, success metrics, and short justification for each database choice.
Sample Answer
Direct answer
Memo: Datastore recommendation for the 1M-daily-user platform
Recommendation: a three-store hybrid architecture: a key-value store for sessions, a document store for the product catalog, and a columnar warehouse for analytics, connected by a single event stream. No single database meets all three workloads' latency, schema, and query-shape requirements at once, and the operational cost of three well-chosen managed stores is lower than the cost of one database straining to do all three jobs badly.
Constraints
- 1,000,000 daily active users; session and catalog reads must stay fast under that load (target: under 50ms p95, 95th-percentile latency, for session reads; under 150ms p95 for catalog page reads).
- Product catalog has variable, category-specific attributes.
- Analytics workloads (usage reporting, product performance) must never compete with the user-facing read path for resources.
- Team is not staffed to run more than a small number of self-managed database clusters, so managed services are preferred over self-hosted where the cost delta is reasonable.
Proposed architecture
| Component | Store | Mapping to requirement |
|---|---|---|
| User sessions | Managed key-value store (Redis-compatible or DynamoDB), with a time-to-live so expired sessions clean up automatically | Sessions are simple key-based lookups with extreme read frequency and no need for cross-session transactions: the textbook key-value case |
| Product catalog | Document store (MongoDB/DynamoDB) behind a read cache | Per-category attribute variation fits a flexible-schema document model far better than a rigid relational table; the cache absorbs most read traffic so p95 stays low even at 1M DAU (daily active users) |
| Analytics | Columnar warehouse (BigQuery/Snowflake), fed by CDC (change data capture: streaming each committed change out of the operational stores as an event) | Isolates heavy scans and aggregations from the two latency-critical stores above entirely |
Session and catalog changes flow into the warehouse asynchronously through the same event stream, so analytics is always a few seconds to a few minutes behind live traffic and never in the critical path of a user-facing request.
Success metrics
- p95 session-read latency under 50ms, measured continuously from application-level monitoring.
- p95 catalog-page-read latency under 150ms.
- Zero user-facing queries served directly against the analytics warehouse (verified by checking the warehouse's query log for any connection from the application's read path, which should be none).
- CDC propagation lag into the warehouse under 5 minutes at the 95th percentile, so daily reporting is never working from stale data.
Justification, one line each
- Key-value for sessions: matches the access pattern exactly (point lookup by session ID) and native TTL support removes the need for a manual cleanup job.
- Document store for catalog: flexible schema avoids forcing every product category into one rigid table shape, and read caching gets latency well under the 150ms target without over-provisioning the primary store.
- Columnar warehouse for analytics: isolates expensive scans from the two operational stores, protecting their latency targets, and is purpose-built for the aggregate queries reporting actually needs.
Trade-offs and pitfalls
The main cost of this design is operational: three managed services instead of one, and an event pipeline connecting them that needs its own monitoring for lag and delivery failures. That is the right trade at 1M DAU with a session-and-catalog-shaped workload; at a much smaller scale, or if the catalog's schema were actually uniform across categories, a single well-cached relational database could meet all three requirements and this split would be unjustified complexity. The memo's recommendation should be revisited if catalog attributes converge to a fixed schema, or if daily active users drop by an order of magnitude and the operational overhead of three stores stops paying for itself.
You inherit a backend using a single relational DB that occasionally causes maintenance windows. Propose an incremental modernization roadmap over 12 months to improve availability and scalability while minimizing risk. Include milestones, datastores to introduce, and metrics to measure progress.
Sample Answer
Direct answer
Modernize in four roughly quarter-long stages, each one shippable and reversible on its own, moving from "reduce load on the single database" to "remove the database as a single point of failure" to "give specific workloads their own store" to "prove the new architecture under real failure." Trying to jump straight to a target polyglot architecture in one project is the riskiest version of this roadmap; sequencing it so every stage is independently valuable means the team keeps shipping and keeps a working system even if a later stage gets delayed or cut.
Roadmap
Months 1-3: reduce load without adding new systems. Add a read replica (a copy of the database, kept in sync with the primary, that only serves read queries) and route read-only traffic to it, add a cache (Redis) in front of the hottest read queries, and instrument the database with the monitoring needed to actually see what's causing the maintenance windows (long-running migrations, lock contention, a specific slow query pattern, vacuum/bloat buildup: bloat is wasted space left behind by old, no-longer-needed row versions, and vacuum is the background process, native to databases like Postgres, that reclaims it). Milestone: read replica live and serving a measured percentage of read traffic; maintenance-window root cause identified with data, not guesswork. Metric: reduction in average query latency and load on the primary, and a documented root cause for the existing maintenance windows.
Months 4-6: remove single points of failure in the primary. Move to a managed high-availability configuration (automatic failover to a standby) if not already in place, and start decomposing the riskiest maintenance operations (schema migrations, large backfills) into online, zero-downtime techniques instead of the blocking operations likely causing the windows today. Milestone: a failover has been tested (not just configured) and completes within a defined time budget; at least one previously blocking maintenance operation now runs online. Metric: mean time to recover from a primary failure, measured in a drill, and number of maintenance windows still required per month (target: trending down from whatever the current baseline is).
Months 7-9: introduce a second store for the workload that benefits most. Using the root-cause data from stage 1, pick the single highest-value split: commonly, moving heavy read-mostly or full-text-search traffic to a purpose-built store (a search engine, or a read-optimized cache layer), or moving an analytics/reporting workload off the primary entirely via change data capture (CDC: streaming committed database changes as events) into a small warehouse. This is deliberately one new store, not several, to keep the risk and the learning curve bounded. Milestone: the chosen workload is fully served from the new store in production, with the old path removed, not left running in parallel indefinitely. Metric: the specific latency or load improvement that was the stated goal of picking that workload first.
Months 10-12: validate under real failure, then decide the next split. Run a deliberate failure drill against the now-partially-decomposed system (kill the primary, kill the new secondary store, and check both recovery paths), and use everything learned in stages 1-3 to decide whether a second workload split is warranted or whether the system has reached a stable, "good enough" state. Milestone: a documented failure drill with measured recovery times for both stores. Metric: availability over the full 12 months, measured against the baseline from before the roadmap started, and a written recommendation for whether to continue splitting workloads in year two.
Trade-offs and pitfalls
- Resist decomposing everything in one project. Each new store is a new thing to monitor, upgrade, and be paged for; splitting incrementally and proving each stage under real failure before moving to the next is what keeps this roadmap low-risk relative to a big-bang rearchitecture.
- Don't skip the root-cause step in stage 1. A team that jumps straight to "add a cache" or "split out analytics" without first measuring what's actually causing the maintenance windows risks solving the wrong problem and still having the windows a year later.
- A read replica and a cache reduce load, but they don't remove the primary as a single point of failure. Stage 2 exists because stage 1 alone can create a false sense of resilience while the actual availability risk (the primary going down) is untouched.
- Every milestone above is deliberately measurable, not just "done." A roadmap stage that can't point to a number (latency, recovery time, load percentage) invites the temptation to declare victory without verifying it, which is exactly the failure mode a 12-month, low-risk-by-design roadmap is meant to avoid.
Create an Architecture Decision Record (ADR) outline a junior SA would use to choose between a managed database service (DBaaS) and a self-hosted database for an SMB client. Include sections for context, decision drivers, options considered, trade-offs, decision, consequences, and migration notes.
Sample Answer
Direct answer
An Architecture Decision Record (ADR: a short, versioned document that captures one architectural decision, the reasoning behind it, and what it costs) for this choice should recommend a managed database-as-a-service (DBaaS: a cloud provider that operates the engine, patching, backups, and failover (automatically switching to a standby system if the primary one fails) for you) as the default for a small or midsize business (SMB), because the deciding factor for most SMB clients isn't the database technology, it's whether anyone on staff can be the on-call database administrator, and for a small team the honest answer is usually no.
Structured elaboration
An ADR earns its usefulness from its structure, not its length:
- Context: the situation forcing a decision now (a new service being stood up, a growth trigger, a compliance requirement), described in plain terms a non-technical stakeholder could follow.
- Decision drivers: the small list of things that actually determine the answer (team size and skills, budget, expected growth, uptime requirements), ranked, not just listed.
- Options considered: every option that was genuinely evaluated, including the ones not chosen. An ADR missing rejected options gives a future reviewer nothing to push back on when the decision needs revisiting.
- Trade-offs: what each option costs and gives up, ideally as a short table, so the comparison survives being read without the surrounding prose.
- Decision: the choice, stated as one sentence, with no hedging.
- Consequences: what becomes easier and what becomes harder as a direct result, including things the team is explicitly accepting as a cost.
- Migration notes: what would have to happen to change this decision later, and how expensive that would be, so a future team isn't rediscovering the exit cost from scratch.
Worked example
ADR-014: Managed PostgreSQL vs Self-Hosted PostgreSQL for the Order Management Service
Status: Accepted
Context: We are standing up a new order management service for a 12-person e-commerce SMB client with no dedicated infrastructure or database operations staff. The service needs a relational database for orders, inventory, and payments records.
Decision drivers: (1) no in-house database operations capacity, (2) predictable monthly cost more valuable than the lowest possible infrastructure price, (3) the client's engineers are comfortable with SQL but have never run production failover or point-in-time recovery.
Options considered: (A) a managed PostgreSQL service (automated backups, patching, and failover); (B) self-hosted PostgreSQL on virtual machines, operated by the client's own engineers.
Trade-offs:
| Dimension | A: Managed | B: Self-hosted |
|---|---|---|
| Setup effort | Low, provisioned in under an hour | Higher, requires OS hardening, backup tooling, and monitoring built from scratch |
| Ongoing operational load | Near zero, vendor handles patching and failover | Falls on the client's own engineers, who have no prior production database operations experience |
| Cost | A per-hour service premium over raw compute | Lower raw infrastructure cost, but the engineer-hours to operate it reliably are a real, recurring cost the client is not budgeting for |
| Customizability | Limited to what the vendor exposes | Full control of extensions, OS-level tuning, and configuration |
Decision: Adopt Option A, a managed PostgreSQL service.
Consequences: The client gives up some configuration flexibility and pays a service premium, in exchange for automated backups and failover the client's own team is not currently equipped to build or operate. On-call burden for database availability moves to the vendor.
Migration notes: If the client later hires dedicated operations staff or hits a feature the managed tier doesn't support, the standard PostgreSQL wire protocol and dump/restore tooling keep a future move to self-hosted realistic; budget for a planned migration project rather than an emergency one if that day comes.
Trade-offs & pitfalls
Self-hosted is still the right call when a specific, named requirement rules out every managed option, for example a compliance mandate requiring physical control of the hardware that no vendor will contractually satisfy, or a need for a database extension or version no managed tier offers. The most common mistake a junior architect makes here is writing an ADR that states only the chosen option and skips "options considered" entirely, which reads as a justification written after the fact rather than a decision made with the alternatives genuinely on the table.
Unlock Full Question Bank
Get access to all 28 Database Selection and Trade-offs interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.