# When a Relational Database Is the Better Choice

An honest look at the apps where a relational database fits better than documents, such as money moving between many records, reports that join data in ways nobody planned, and a shape many teams must share, and why many apps use both.

Journeyman · MongoDB · Database · Updated November 19, 2026

By Gregor Dzierzon

## After this lesson you can

- Tell which signs in an app's data point to a relational database and which point to documents
- Choose a document database, a relational database or both for an app, and explain the choice with its trade-offs
- Choose between a conditional update, an embedded document, a transaction and a relational database to keep a store's data right

## Key takeaways

- Documents fit data that's read together, holds lists and changes shape, and a relational database fits data that's shared, cross-linked and changed together.
- When most writes must change several records at once, as money moving between accounts does, a relational database does that everyday work with less effort.
- Normalized tables answer questions nobody planned for, because SQL can join them any way a report needs.
- When many teams and apps write the same data, rules the database enforces, such as foreign keys and NOT NULL, protect it from all of them.
- Many apps use both, each for the part of the data it fits, and a team's skills are a fair reason to choose too.

Choosing a database is one of the few decisions in a project that's expensive to undo. You'll make it at the start of a new app, argue it in a job interview, or face it when an app starts to strain. This course is about MongoDB, and it's still honest about where MongoDB isn't the best fit: knowing that is part of using it well.

Riverbend Bike Shop's store runs on MongoDB, and it's doing well. Then three requests arrive in the same week. The bookkeeper wants every sale recorded as money moving between accounts. The owner wants sales reports sliced every way she can think of. And a second team will build a warehouse app that writes to the same data. Should Riverbend switch?

## Money that moves between many records

Picture a bank transfer: one account goes down and another goes up, and the two must always change together. Bookkeeping works the same way. Each sale moves money between several accounts (cash, sales, sales tax owed), and the books must balance after every single one.

That's where relational databases grew up. A transaction that changes four tables at once is their everyday work, and rules such as "this account must exist" are checked on every write. MongoDB has real transactions too, as *Transactions, and Why You'll Need Them Less* showed, but they're the exception it's built around. When nearly every write must change several records together, you're working against the model: that data fits a relational database better.

## Questions nobody planned for

Documents are shaped for the questions you know: an order holds its lines because the order page shows them together. Reports ask questions nobody planned for. Sales by brand by month, then by customer's city, then only for returning customers: each one cuts the same data a new way.

Normalized tables, with each fact stored once, can be joined any way a question needs, and SQL's `JOIN` and `GROUP BY` were made for that. Most reporting and spreadsheet tools also speak SQL first. MongoDB's aggregation pipeline, which Module 4 teaches, answers reports well when you know them ahead of time; when every week brings a new angle, a relational database usually takes less work.

## A shape many teams must share

A document's flexibility is a gift for one app that knows its own data. When several teams and apps write the same data, the shape becomes a contract. A relational database enforces that contract for everyone: a column that's `NOT NULL`, a `CHECK` that a price is at least 0, a foreign key that refuses an order line for a missing product. MongoDB's validator checks a document's own fields, as *Schema Validation with $jsonSchema* showed, but nothing checks that a reference points somewhere.

And there's the team itself. A team that knows SQL well, with the tools and backups already in place, has a fair reason to stay there. That's a real cost, not a weakness.

## Where documents still win, and using both

None of this makes Riverbend's store a mistake. Its catalog holds bikes, helmets and lights with different fields; a product page reads a product and its newest reviews at once; carts and orders hold their own lists. That's what documents do best.

| Signs that point to documents | Signs that point to a relational database |
|---|---|
| Data read together, such as an order and its lines | Data shared and cross-linked, such as accounts many entries touch |
| Lists inside a record | Most writes change several records at once |
| Shapes that differ or change often | One fixed shape that many teams depend on |
| Questions known ahead of time | Reports that join the data in new ways |

Many apps use both, each for the part of the data it fits. Riverbend's answer: keep the store in MongoDB, send each finished sale to a relational database for the books and the reports, and give the warehouse app its own data with an agreed way to read the store's.

## Check yourself

2 questions to try on the lesson page.

## So what

The best answer to "SQL or MongoDB?" is usually "for which data?" You can now name the signs on each side, and say plainly when documents aren't the right tool, which is what makes people trust your choice when they are.

## Key terms

- [Relational Database](https://www.ask-codey.com/glossary/relational-database)
- [Document Database](https://www.ask-codey.com/glossary/document-database)
- [ACID Properties](https://www.ask-codey.com/glossary/acid-properties)
- [Schema](https://www.ask-codey.com/glossary/schema)

## Related

- [Where Documents Fit, and Where They Don't](https://www.ask-codey.com/lessons/mongodb-where-documents-fit)
- [Transactions, and Why You'll Need Them Less](https://www.ask-codey.com/lessons/mongodb-transactions-and-why-you-need-them-less)
- [If You Know SQL: One Store Designed Both Ways](https://www.ask-codey.com/lessons/mongodb-if-you-know-sql-one-store-both-ways)

Source: https://www.ask-codey.com/lessons/mongodb-when-relational-is-better
