SQL vs NoSQL — and When MongoDB Fits
Your bookshop app shows a book page 10,000 times a day. In a relational database, that page might join a books table, a genres table, a book_genres link table and a publishers table on every view. A document database asks a different question: why not keep the page's data together from the start?
The rule
Tables split data and join on read; documents keep together what is read together.
SQL (relational) databases such as PostgreSQL and MySQL store data in tables with a fixed set of columns. Each fact is stored once, and queries join tables back together. They shine when data is highly interlinked and asked about in many different ways.
NoSQL is an umbrella term for databases that are not table-based. It covers document stores (MongoDB), key-value stores, wide-column stores and graph databases. MongoDB is a document store.
| Relational | MongoDB | |
|---|---|---|
| Unit of data | row in a table | document in a collection |
| Shape | fixed columns, changed with ALTER TABLE | flexible, can vary per document |
| Related data | separate tables plus joins | embedded, or referenced by id |
| Query language | SQL | query documents and methods |
| Growing bigger | usually a bigger server | built-in sharding across servers |
Two myths to drop: MongoDB is not schema-less chaos (you can enforce a schema with validation rules), and it does support multi-document ACID transactions. The difference is what the design leans on by default.
The shortcut
Ask "What does my app read together?" Then check the fit.
Find the reads
The busiest screen is the book page: one book with its genres, publisher and ratings.
MongoDB tends to fit: content and catalogues, user profiles, event logs, IoT readings, and apps whose data shape keeps evolving. It fits less well when nearly every operation must update many separate, heavily linked records at once.
Drills
Answer fast — trust the rule.
Which kind of database is MongoDB?
A relational database typically answers "show this book with its genres" by…
Which statement about MongoDB is true?
Which project is the weakest natural fit for MongoDB?
Remember
- Tables split data and join on read; documents keep together what is read together.
- Shortcut: ask what the app reads together, whether shapes vary, and how tangled the links are.
- Trap: MongoDB is not structure-free and not transaction-free.
