1.Document-oriented databases
MongoDB stores data as documents — JSON-like records that can nest objects and arrays — instead of rows in a table. Each document lives in a collection, and documents in the same collection do not have to share one fixed set of fields.
Key features
- A document is a set of field-value pairs, stored in BSON, a binary superset of JSON
- A collection groups related documents, the rough equivalent of a table
- Documents can nest objects and arrays, so related data can live in one document
- MongoDB is the reference document database — the pattern is not unique to it
- The document model maps closely onto objects in application code
Document terms vs. their relational rough-equivalent
- document — field-value pairs
- embedded object — nested inline
- array — a list, nested too
Command
{
"field": "value",
"nested": { "field": "value" },
"list": ["value", "value"]
}A document is a JSON-like BSON record; a collection groups documents that do not have to share one fixed schema. Nesting replaces some joins.