MongoDB — The Judgement Behind Document Databases
The Schema Did Not Disappear; It Moved
In one line
A document database is not a "database without a schema" but a database where the application holds the schema. The schema has not disappeared; it has only moved to a different place.
Why it is needed — if you misread "flexible"
When people first use MongoDB, the most common expectation is "I do not have to decide the columns in advance, so I can build quickly." That is true, but it is hard to see where the cost went.
In an RDB, if you put a string into qty, it is rejected on the spot. In a document DB,
it goes in. And you find out only months later when an aggregation query spits out strange values.
By then you can no longer tell which documents went wrong, or since when.
That is why the document databases used in real work usually have a schema. You either enforce it with $jsonSchema,
or filter it in the application layer (Mongoose, Pydantic). One of the two is always there.
So what is actually different
The difference is not whether there is a schema but what comes along together in a single read.
In an RDB, an order and its line items are split into two tables and joined together. In a document DB, you can embed the line items inside the order document.
{ _id: 1, customer: "김", lines: [ { name: "가방", qty: 2 }, { name: "신발", qty: 1 } ] }
If what the order screen needs is exactly this shape, one read is enough. There is no join and no N+1. Storing data in the shape you read it is the value of a document DB.
In the field
So the decision criterion narrows down to one — is it read together, or does it change separately?
If the line items are always read together with the order and are never edited separately outside the order, embed them. Conversely, if many orders point to the same thing, like product information, and a change in value must be reflected in all of them, keep it as a reference and manage it separately. If you embed it, then to fix that product name you have to find and fix every document that holds it.
This is the answer interviewers actually want to hear when they ask "have you used MongoDB?" Not the query syntax, but how far you embedded, where you cut it off, and why.