Document Databases
Document databases store data as semi-structured documents — typically JSON or BSON — rather than fixed rows and columns. They support flexible schemas, nested structures, and queries within documents, suiting workloads where data shapes vary or evolve frequently.
itDatabases and data storage | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic - Document Databases
A document database keeps a record as one named bundle of values, nested objects, and arrays. Think of an order with its status, delivery address, and line items in one place. It exists because applications often handle those pieces together, while pulling them apart into several records can make every ordinary read feel like a small archaeology project.
The useful idea is the aggregate, not JSON with a new hat. An aggregate is the data an application reads and changes as one boundary. JSON supplies objects, arrays, and scalar values. A database may store something JSON-like instead, with its own types and limits, because databases enjoy adding footnotes to otherwise pleasant nouns.
The first hard choice is embedding versus a reference. Embed a bounded value owned by one parent and usually read with it. An order can embed the delivery address used at purchase, so a later customer profile change does not rewrite history. Reference an entity with an independent lifecycle, such as the customer. Do not embed every order inside one customer document unless the plan is to discover, at an inconvenient moment, that history has no natural stopping point.
Flexible schema does not mean no schema. A collection may accept documents with different fields, but the application still needs stable names, types, required values, and version rules. Validation and migration rules keep controlled variation from becoming a collection of nearly identical field names that have quietly become rivals.
Indexes and partition keys are the second ambush. An index is an extra access path for a frequent filter or sort, not a decorative label for a collection. It speeds selected reads but costs storage and write work. A partition key decides where a document belongs in a distributed store. One attractive value that receives most traffic is still one hot partition, even when many machines are waiting politely nearby.
The final surprise is that document databases do not share one consistency story. A single-document write can be atomic in MongoDB. CouchDB uses revisions and can expose conflicts that the application must resolve. Products differ on transactions, replication, and visibility. The category name is a signpost, not a guarantee.
Read the Intro when you need the full mental model. Use Slides to compare the design choices quickly. Keep the Cheatsheet nearby when reviewing an aggregate, index, or partition key. Then use the practice reference to turn one workload into explicit boundaries and tests. The database is only storing documents. The difficult part is deciding which facts belong together, which must stay apart, and how the answers survive real traffic.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://datatracker.ietf.org/doc/html/rfc8259
Supports
- JSON as a text interchange format
- Objects as unordered name-and-value pairs
- Arrays as ordered values
- JSON primitive values and UTF-8 interoperability guidance
- JSON standards link rationale
- https://www.mongodb.com/docs/manual/core/document/
Supports
- BSON documents as field-and-value records
- Nested documents and arrays
- BSON as a binary representation with types beyond JSON
- MongoDB documents link rationale
- https://www.mongodb.com/docs/manual/data-modeling/embedding/
Supports
- Embedded objects and arrays
- Retrieval of related data in one operation
- Single-document atomic update benefit
- Ownership-oriented embedding cases and document size limit
- Embedding link rationale and related quiz answers
- https://www.mongodb.com/docs/manual/data-modeling/referencing/
Supports
- References between independently stored documents
- Reference cases for changing data, many-to-many relationships, large hierarchies, and independent queries
- Normalization and duplication tradeoffs
- Reference link rationale and related quiz answers
- https://www.mongodb.com/docs/manual/core/indexes/index-types/
Supports
- Single-field, compound, multikey, wildcard, geospatial, hashed, and text index categories
- Index types link rationale
- https://www.mongodb.com/docs/manual/core/indexes/index-types/index-compound/create-compound-index/
Supports
- Compound index field order and leading-prefix behavior
- Compound-index quiz answer
- https://www.mongodb.com/docs/manual/core/write-operations-atomicity/
Supports
- Single-document write atomicity
- Multi-document transaction availability
- Additional cost of distributed transactions
- Schema design as a way to reduce broad transaction needs
- Atomicity link rationale and related quiz answers
- https://www.mongodb.com/docs/manual/core/schema-validation/handle-invalid-documents/
Supports
- Rejecting invalid writes by default
- Warning while allowing invalid writes
- Validation during migrations
- Flexible-schema quiz answer
- https://learn.microsoft.com/en-us/azure/cosmos-db/partitioning
Supports
- Logical partitions grouped by partition-key value
- Hash mapping of logical to physical partitions
- Even throughput distribution and hot-partition risk
- Cross-partition query cost and transaction boundaries
- Partitioning link rationale and related quiz answer
- https://docs.couchdb.org/en/stable/intro/overview.html
Supports
- Multi-version concurrency control
- Atomic single-document updates
- Integrated document, query, and replication model
- CouchDB overview link rationale
- https://docs.couchdb.org/en/stable/replication/conflicts.html
Supports
- Revision identifiers and stale-write conflict response on one node
- Competing revision branches introduced through replication
- Application responsibility for conflict resolution
- Conflict-model link rationale and related quiz answer
- https://www.apache.org/foundation/board/calendar-2005-2009.html
Supports
- Apache CouchDB project establishment in November 2008
- Timeline milestone
- https://archive.apache.org/dist/couchdb/
Supports
- Apache CouchDB 0.10 distribution in October 2009
- Timeline milestone
- https://www.mongodb.com/company/our-story
Supports
- MongoDB launch in 2009
- Timeline milestone
- https://aws.amazon.com/about-aws/whats-new/2012/01/18/aws-announces-dynamodb/
Supports
- DynamoDB launch in January 2012
- Managed NoSQL timeline milestone
- https://azure.microsoft.com/en-us/blog/new-azure-services-and-updates-expand-openness-choice-and-flexibility/
Supports
- Azure DocumentDB public preview in August 2014
- Timeline milestone
- https://investors.mongodb.com/static-files/5b7b3bbe-5f2f-42fe-9689-469036fc3ff9
Supports
- MongoDB Atlas launch in 2016
- Timeline milestone
- https://azure.microsoft.com/en-us/blog/azure-cosmos-db-microsofts-globally-distributed-multi-model-database-service/
Supports
- Azure Cosmos DB general availability in May 2017
- Timeline milestone
- https://www.mongodb.com/company/blog/product-release-announcements/mongodb-multi-document-acid-transactions-general-availability
Supports
- MongoDB 4.0 multi-document ACID transactions in June 2018
- Timeline milestone
- https://aws.amazon.com/about-aws/whats-new/2019/01/amazon-documentdb-with-mongodb-compatibility-generally-available/
Supports
- Amazon DocumentDB general availability in January 2019
- Timeline milestone
- https://www.mongodb.com/docs/atlas/
Supports
- MongoDB Atlas as a multi-cloud database service
- MongoDB Atlas product placement
- https://docs.couchbase.com/cloud/tutorials/buckets-scopes-and-collections.html
Supports
- Couchbase buckets, scopes, collections, and document organization
- Couchbase Capella product placement
- https://learn.microsoft.com/en-us/rest/api/cosmos-db/documents
Supports
- Azure Cosmos DB document data model support
- Azure Cosmos DB product placement
- https://docs.aws.amazon.com/documentdb/latest/devguide/compatibility.html
Supports
- Amazon DocumentDB MongoDB compatibility and functional differences
- Amazon DocumentDB product placement
- Field Note on compatibility testing
- https://firebase.google.com/docs/firestore/data-model
Supports
- Cloud Firestore documents and collections data model
- Cloud Firestore product placement
- https://www.mongodb.com/company/blog/technical/embedded-objects-other-index-gotchas
Supports
- Production design review involving embedded-object index behavior
- Field Note on measuring document and index growth
