Quick revision
The short answer
We review the choice against the data and its access patterns, not the stated reason. Accounts, transactions and balances need atomic multi-record updates and strong integrity; MongoDB does support multi-document transactions, but relational constraints and joins fit a ledger more naturally. Schema change is manageable in PostgreSQL with Flyway or Liquibase and JSONB for truly variable parts, so after weighing team experience, operations, backups and reporting, we record the decision in an ADR with what would make us revisit it.
What to remember
In this answer, we reviewed a proposal to use MongoDB for accounts, transactions and balances. We clarified the access patterns and invariants, saw that MongoDB supports multi-document transactions but that relational constraints and joins fit a ledger more naturally, showed that schema change is manageable with Flyway or Liquibase and JSONB, weighed team experience, operations, backups and reporting, and recorded the outcome in an ADR with clear triggers for revisiting.
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.
We review the choice against the data and its access patterns, not the stated reason. Accounts, transactions and balances need atomic multi-record updates and strong integrity; MongoDB does support multi-document transactions, but relational constraints and joins fit a ledger more naturally. Schema change is manageable in PostgreSQL with Flyway or Liquibase and JSONB for truly variable parts, so after weighing team experience, operations, backups and reporting, we record the decision in an ADR with what would make us revisit it.
Why this question is asked
Reviewing another team's technology choice is a delicate job. If we simply say no, we lose their trust; if we wave it through, we may approve a design that loses money. Interviewers ask this to see whether we can review a decision on its merits: separate the stated reason from the real requirements, check facts about both options, and leave a written record. In this answer, we will clarify what the data needs, look at what MongoDB and a relational database each offer for a ledger, test the 'schema will change a lot' argument, consider the operational side, and write it up as an ADR.
1Clarify the Access Patterns and Consistency Needs
We start by asking the team questions rather than giving an opinion. What are the main operations, and how often? For a ledger they are typically: post a transfer, which debits one account and credits another; read an account's balance; list an account's transactions; and produce statements and reconciliation reports. What must always be true? The sum of all postings for a transfer is zero, a balance never goes below its limit, and no transaction is recorded twice.
These answers matter more than the database names. A transfer touches at least two accounts and two or more postings, and must be all-or-nothing: if the debit is saved and the credit is not, money disappears. That is an atomic multi-record update with strong integrity rules, exactly the kind of workload where the database's guarantees carry most of the correctness.
2What Each Option Offers for a Ledger
MongoDB stores JSON-like documents. Since version 4.0 it supports multi-document ACID transactions on replica sets, and since 4.2 on sharded clusters, so the claim that MongoDB cannot do transactions is outdated. But integrity rules are mostly the application's job: there are no foreign keys, and the schema validation it offers is weaker than relational constraints. Cross-collection queries use the aggregation framework's $lookup, which works but is not where it shines. A ledger also benefits from the database refusing a posting for an account that does not exist, or a duplicate idempotency key, even when the application has a bug.
A relational database expresses these rules directly. A foreign key from postings to accounts, a unique key on the transfer's idempotency key, a CHECK on amounts, and a transaction that locks the two account rows while updating balances give us integrity that does not depend on every code path being right. Statements and reconciliation are joins and aggregations, which SQL handles naturally.
| Need | PostgreSQL | MongoDB |
|---|---|---|
| Atomic transfer across records | transactions, row locks | multi-document transactions (4.0+) |
| Account must exist | foreign key | application code |
| No duplicate transfer | unique constraint | unique index, works |
| Statements and reconciliation | joins, SQL aggregates | aggregation pipeline, $lookup |
| Variable metadata | JSONB column | native documents |
| Schema changes | migrations with Flyway or Liquibase | flexible, but old shapes remain |
3Testing the 'Schema Will Change a Lot' Argument
The team's reason deserves a fair hearing. What will change? Often it turns out to be metadata: new transaction types, extra attributes from payment partners, fields for a new country. The core of a ledger, accounts, transfers and postings with amounts and timestamps, is one of the most stable data models in software, and has been for centuries.
In a relational database, schema changes are routine with migration tools. Flyway or Liquibase run versioned scripts at deployment, so adding a column or a table is a small reviewed change, and PostgreSQL can add a nullable column without rewriting the table. For the truly variable parts, a JSONB column holds partner-specific attributes without any migration. Notice also that a schemaless store does not remove schema work; it moves it into application code, which must handle every document shape ever written.
4Team Experience, Operations and Reporting
Technical fit is not the whole picture. If the team has deep MongoDB experience and none with PostgreSQL, that counts, though for a ledger it rarely outweighs integrity needs. We also ask about operations: does the company already run, back up, monitor and restore MongoDB, or would this be the first cluster? Who is on call for it? How do restores to a point in time work, and have they been tested?
Then reporting. Finance and compliance will want statements, reconciliations and ad hoc queries, often through tools that speak SQL. If the data lives in MongoDB, we need a pipeline to a warehouse sooner. None of this means MongoDB can never be right; it means the team should see the full cost.
5Recording the Decision in an ADR
An architecture decision record, ADR, is a short document that states the context, the options considered, the decision and its consequences. Writing it turns a debate into something the next engineer can understand in five minutes. Here, the ADR would say that the ledger's core needs atomic multi-record updates and database-enforced integrity, that PostgreSQL with Flyway migrations and JSONB for variable metadata meets the flexibility need, and that MongoDB was considered and set aside for the ledger core.
Importantly, it records what would make us revisit: for example, if most new requirements turn out to be large variable documents rather than ledger records, or if the team later needs a capability PostgreSQL cannot provide. A recorded trigger for revisiting keeps the decision honest and shows the team its concern was taken seriously.
- List operations and invariantstransfers, balances, statements
- Need atomic multi-record updates and integrity?for a ledger, yesYesPrefer database-enforced rulesNoDocument store may fit
- Is the variable part small?metadata, partner fieldsYesRelational core plus JSONBNoConsider a separate document store
- Check team, operations, reportingskills, backups, SQL tools
- Write the ADRdecision and revisit triggers
5 steps in order. Play them, or step through them one at a time.
6Follow-up questions
Would you ever approve MongoDB here?
For parts of the service, yes: for example a store of raw partner payloads or flexible customer preferences. If the team had strong MongoDB operations and the core ledger used transactions carefully with application-level checks, it could work, but I would want them to accept explicitly that integrity then depends on code rather than the database.
How do you keep the review from feeling like a veto?
By asking about requirements first, giving facts about both options, including what MongoDB does well, and documenting the decision with triggers for revisiting. The goal is a shared conclusion, not winning an argument.
What about storing balances at all?
Many ledgers store only postings and compute balances, or store balances as a cache updated in the same transaction. Either way the update must be atomic with the postings, which again favours strong transactional guarantees.
7Conclusion
In this answer, we reviewed a proposal to use MongoDB for accounts, transactions and balances. We clarified the access patterns and invariants, saw that MongoDB supports multi-document transactions but that relational constraints and joins fit a ledger more naturally, showed that schema change is manageable with Flyway or Liquibase and JSONB, weighed team experience, operations, backups and reporting, and recorded the outcome in an ADR with clear triggers for revisiting.
Open with
I would start by understanding the data rather than debating databases. I would ask the team for the main operations and the rules that must always hold: a transfer debits one account and credits another atomically, postings for a transfer sum to zero, no duplicate transactions, balances within limits.
Then, if they want more
That is a workload of atomic multi-record updates with strong integrity. MongoDB does support multi-document transactions since 4.0, so it is not impossible, but integrity like foreign keys and most constraints becomes application code, while a relational database enforces them itself, and statements and reconciliation are natural joins and aggregates in SQL.
On the schema argument, I would find out what actually changes; usually it is metadata, and the ledger core is very stable. Flyway or Liquibase make schema changes routine, and a JSONB column handles the truly variable attributes. I would also look at team experience, whether we already operate and restore MongoDB, and finance's reporting needs.
Then I would write an ADR with the context, options, decision and what would make us revisit it, so the team's concern is recorded and the reasoning is visible later.
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
- PostgreSQL documentation, MySQL reference 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 "A team wants to use MongoDB for a new service because 'the schema will change a lot'....": https://scrivio-interview-library.netlify.app/databases/database-operations/4e66481e20/