What a Document Is
A document database stores data as semi structured records, usually JSON or BSON. Each document is a self contained object with nested fields, arrays, and sub objects. A blog post document can hold its title, body, tags, and even its comments all in one place.
How It Differs from Tables
- A relational row has a fixed schema defined ahead of time.
- A document has a flexible schema, so two documents in the same collection can have different fields.
- Related data is often nested inside one document rather than joined across tables.
Why Teams Choose It
- The shape of a document often matches the shape of an object in code, reducing translation work.
- You can evolve the schema by simply writing new fields, without a migration that rewrites every row.
- Reading one entity is a single lookup because everything lives together.
The Tradeoff
Flexibility shifts responsibility to the application. There is no database enforced structure, so two documents can drift apart in shape. The application must handle missing or differently named fields gracefully.
Key idea
A document database stores flexible self contained records that match how objects look in code, trading enforced structure for schema freedom.