Records as Documents
A document database stores data as documents rather than rows in a fixed table. A document is a self contained object made of field and value pairs, much like a JSON object. In MongoDB documents are grouped into collections, which are loosely analogous to tables.
What Makes It Flexible
- Each document carries its own structure, so two documents in the same collection can have different fields.
- Values can be scalars, arrays, or nested documents, letting one record model a whole object graph.
- There is no required schema up front, which speeds early development and irregular data.
The Tradeoff
Flexibility shifts the burden of consistency onto the application and your indexes. Without discipline a collection drifts into many shapes that are hard to query. Most teams converge on a stable shape over time and may add validation rules later.
A document usually maps to one application object, so a typical read fetches a complete entity in a single lookup instead of joining many tables.
Key idea
A document database stores flexible self contained records grouped into collections, trading enforced schema for the ability to fetch a whole entity in one read.