The Mental Model
Here's the foundation everything else rests on. If you hold these three words in your head — document, collection, _id — the rest of MongoDB falls into place.
Coming from SQL (or never having touched it)
Here's the translation table I keep in my head:
| SQL world | MongoDB world | If you think in JavaScript |
|---|---|---|
| Database | Database | — |
| Table | Collection | an array |
| Row | Document | an object {} |
| Column | Field | an object key |
| Primary key | _id | a unique id |
| JOIN | $lookup / embedding | nested objects |
A document is just a JSON-like object:
{
"_id": ObjectId("65f0c9a2b3..."),
"name": "Avina",
"roles": ["admin", "editor"],
"profile": { "city": "NYC" },
"createdAt": ISODate("2026-06-11T10:00:00Z")
}
Notice three things that make it feel familiar if you've worked with JavaScript:
- Arrays are first-class (
roles) — no separate join table. - Nested objects are first-class (
profile) — the shape mirrors what your UI consumes. - No rigid schema — two documents in the same collection don't have to look identical (though in practice you keep them consistent).
The _id field is special
Every document gets a unique _id. If you don't provide one, MongoDB generates a 12-byte ObjectId — and it's cleverer than a random UUID:
Two consequences worth remembering:
- It's roughly time-sortable — sorting by
_id≈ sorting by creation time. You get a free "created at." - It's generated client-side by the driver, so you know a document's id before it even hits the database.
The size rule
A single document maxes out at 16 MB. That isn't a limitation to fight — it's a design nudge. It stops you from stuffing an unbounded, ever-growing array into one document (which would make every read heavier). When something wants to grow forever, that's your signal to model it differently — which is exactly what the Data Modeling page is about.
What I want you to take away
A MongoDB database holds collections, a collection holds documents, and every document is a JSON-like object with a unique
_id. That's it. Hold onto that and the next page — how these documents are actually stored on disk — will make complete sense.
👉 Next: How It Stores Data