Quick revision
The short answer
The first step is to say plainly that the schema never disappeared: it moved into application code and into every consumer, where it is duplicated and inconsistent. Then we make it explicit, with a validator, an owner and a data contract for each important collection, fund a clean-up of the highest-value data in order of business impact, decide domain by domain whether MongoDB is still the right store, and set the rule that new systems define their schema on write unless flexibility is a deliberate choice.
What to remember
In this answer, we saw that choosing MongoDB to avoid migrations moved the schema into every application and consumer, which is where the data quality cost comes from. Our strategic response makes schemas explicit again with owners, validators and data contracts, funds a clean-up of the highest-value data by business impact, decides domain by domain whether MongoDB still fits, and sets schema-on-write as the default for new systems, with flexibility as a deliberate choice.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The first step is to say plainly that the schema never disappeared: it moved into application code and into every consumer, where it is duplicated and inconsistent. Then we make it explicit, with a validator, an owner and a data contract for each important collection, fund a clean-up of the highest-value data in order of business impact, decide domain by domain whether MongoDB is still the right store, and set the rule that new systems define their schema on write unless flexibility is a deliberate choice.
Why this question is asked
This question is about a decision made a decade ago that looked reasonable at the time and now costs money every quarter. Every analytics project begins with weeks of discovering which fields mean what, which shapes exist, and which records are simply wrong. Interviewers ask it at the most senior level because the answer is not technical cleverness; it is how we diagnose a structural problem, avoid blame, prioritise limited money and change the rules so the problem stops growing. In this answer, we will look at what really happened to the schema, how to make it explicit again, how to choose what to clean, how to decide per domain about the database itself, and what rule to set for new systems.
1What Really Happened to the Schema
Ten years ago the team avoided schema migrations, the scripts that change a relational table's structure. That felt like speed. But a schema is simply the set of assumptions about what fields exist, what they mean and what types they hold, and those assumptions did not go away. Every service that reads a document expects a customer to have an email and an order to have a total. The schema moved out of the database and into code, where each reader implements its own version of it.
Over ten years that produces the costs the question describes. One service writes total as a number, another as a string; a field was renamed in 2019 but old documents keep the old name; a status value nobody remembers appears in two percent of records. Each analytics project rediscovers these facts, writes its own clean-up logic, and arrives at slightly different numbers. So the strategic response starts by naming this clearly to the leadership: we did not avoid schema work, we deferred it and multiplied it.
| Place | What it holds | Problem |
|---|---|---|
| Writer services | each writer's idea of the shape | versions drift over the years |
| Reader services | defensive parsing of old shapes | duplicated, inconsistent rules |
| Analytics pipelines | clean-up logic per project | rebuilt every time, numbers differ |
| The database | nothing enforced | accepts any shape from anyone |
2Making the Schema Explicit Again
The response is to give each important collection what it lacked: an owner, a written schema and a contract. The owner is one team accountable for the collection's shape and quality. The written schema is a JSON Schema kept in that team's repository and applied as a MongoDB validator, starting with validationAction warn to discover violations and moving to error when writers are fixed. The data contract is the promise to consumers: which fields exist, what they mean, how changes are announced and how long old shapes stay supported.
Data contracts matter most for analytics. A downstream team should not read the operational collection and guess. The owner publishes either a documented export, a change stream feeding a warehouse, or events with a versioned schema, and treats breaking it as seriously as breaking a public API.
3Choosing What to Clean First
We cannot clean ten years of data at once, and we should not try. We fund a clean-up program with a clear order: the data with the highest business value and the highest cost of being wrong goes first. Customer identity, orders and money usually lead, because errors there affect revenue, compliance and every report. Historical logs that nobody analyses may never be worth cleaning.
For each candidate we estimate two numbers: what bad data costs today, in analyst days, incidents or wrong decisions, and what cleaning costs. A customers collection where duplicate and malformed records cost analytics roughly 40 days per quarter and cause billing errors is an obvious first target. Each clean-up ends with an enforced validator, so the cleaned data stays clean.
- List collections by business valuemoney, identity, compliance first
- Estimate cost of bad data per quarteranalyst days, incidents, wrong reports
- Estimate cost to clean and enforcefix writers, migrate, add validator
- Is the value clearly higher than the cost?YesFund it this quarterNoLeave it, document the known issues
- Enforce the validator when doneso it stays clean
5 steps in order. Play them, or step through them one at a time.
4Deciding Per Domain Whether MongoDB Still Fits
Some of the pain may come from using a document store where the data is deeply relational. If a domain is all about relationships, constraints and cross-entity reporting, such as accounting ledgers or inventory with strict invariants, a relational database with foreign keys and transactions may serve it better. Other domains fit documents well: product catalogues with varied attributes, user preferences, content.
So we decide per domain, not for the whole company. For each domain we look at its access patterns, its consistency needs and its reporting needs, and we ask whether the schema problem is a governance problem, which validators and ownership fix, or a model mismatch, which they do not. A migration of one domain to PostgreSQL is a significant project, so it needs a clear case; replacing MongoDB everywhere because of a governance failure would repeat the original mistake in the other direction.
5Setting the Rule for New Systems
Finally, we stop the problem from growing. The rule for new systems is that schema-on-write is the default: the shape is defined, validated and owned from the first day, in whatever database the team chooses. Flexibility, such as free-form attributes or user-defined fields, is allowed when it is a deliberate design choice, written down in the design review, and confined to a clearly marked part of the document.
We also communicate this as a correction, not a condemnation. The original decision was made with what people knew then, and parts of it still serve the company. What we change is the assumption that flexibility is free. Measures such as analyst time spent on data preparation and incidents from malformed data let us show over a year or two that the investment pays back.
6Follow-up questions
How do we justify the clean-up budget to executives?
With costs they already pay. We measure how many analyst days each project spends on preparing data, how many incidents or billing errors came from malformed records, and how much rework there was. A program that removes a known, recurring cost is easier to fund than one described as technical hygiene.
Should we pause feature work to fix the data?
Usually not across the board. We attach clean-up to the teams that own the most valuable collections and give them a fixed share of capacity, and we require that any new writer change comes with a validator. That keeps delivery moving while the most expensive problems shrink.
What if a domain moves to a relational database?
We move it with the same care as any migration: dual writes or change data capture to keep both stores in sync, reconciliation reports that compare them, a staged switch of readers, and a period where we can switch back. The cleaned schema we defined becomes the table design.
7Conclusion
In this answer, we saw that choosing MongoDB to avoid migrations moved the schema into every application and consumer, which is where the data quality cost comes from. Our strategic response makes schemas explicit again with owners, validators and data contracts, funds a clean-up of the highest-value data by business impact, decides domain by domain whether MongoDB still fits, and sets schema-on-write as the default for new systems, with flexibility as a deliberate choice.
Open with
I would start by being honest about what happened: we did not avoid a schema, we moved it into every service and every analytics pipeline, where it is duplicated and inconsistent, and that is exactly the cost we now pay on each project.
Then, if they want more
So the response has four parts.
First, make the schema explicit again for the collections that matter: one owning team per collection, a JSON Schema in its repository applied as a validator, starting with warn and moving to error once writers are fixed, and a data contract for consumers, ideally a documented export or event stream for analytics rather than reading operational collections directly.
Second, fund a clean-up program, but prioritised by business impact: customer, order and money data first, using the cost of bad data in analyst days and incidents against the cost of fixing it, and each clean-up ends with enforcement so it stays clean. Third, decide per domain whether MongoDB is still right.
Where the pain is governance, validators and ownership fix it; where the data is truly relational with strong constraints, moving that domain to a relational database may be justified. Fourth, set the rule for new systems: schema-on-write by default, flexibility only as a deliberate, documented design choice.
And I would track analyst preparation time and malformed-data incidents to show the payback.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- MongoDB manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Ten years ago your company chose MongoDB partly to avoid schema migrations. Today data...": https://scrivio-interview-library.netlify.app/databases/mongodb/514af69097/