Document Database
Definition
NoSQL database that stores data in document format, typically JSON-like structures, allowing for flexible and scalable data management.
Use Cases
- The New York Times: Storing and serving article content with varying fields (sections, authors, tags, media, and evolving metadata) for publishing workflows. — Used MongoDB as a document database to model articles and related content as flexible JSON-like documents, enabling schema evolution as editorial needs changed. (Faster iteration on content features and easier handling of changing article metadata without frequent schema migrations.)
- Craigslist: Managing diverse listing data where different categories (jobs, housing, for-sale) have different attributes and change over time. — Adopted MongoDB to store listings as documents, allowing each listing type to have its own set of fields while still supporting indexing and queries. (Improved developer agility for adding new listing attributes and handling heterogeneous data structures.)
- Stack Overflow: Storing and querying large volumes of semi-structured data such as posts and related metadata that can evolve over time. — Used MongoDB for parts of its architecture to store JSON-like documents and support flexible data modeling and indexing. (Simplified handling of evolving data shapes and supported rapid product changes for certain workloads.)
Provider Equivalents
- AWS: Amazon DocumentDB (with MongoDB compatibility)
- Azure: Azure Cosmos DB (for MongoDB) and Azure Cosmos DB (Core/NoSQL)
- GCP: Firestore
- OCI: Oracle NoSQL Database
Frequently Asked Questions
- What's the difference between a document database and a relational database?
- A document database stores data as documents (often JSON-like), where each record can have different fields. A relational database stores data in tables with a fixed schema (columns) and uses joins to relate tables. Document databases are often easier for rapidly changing or semi-structured data, while relational databases excel at complex transactions and strict consistency across many related tables.
- When should I use a document database?
- Use a document database when your data is naturally JSON-like, varies between records, or changes frequently (for example: user profiles, product catalogs, content management, event data). It’s also a good fit when you want to retrieve an entire object in one read (for example, a full article with metadata) and scale reads/writes horizontally. If you need many multi-table joins and highly normalized data, consider a relational database instead.
- How much does a document database cost?
- Cost depends on the managed service and your workload. Common pricing factors include: provisioned or serverless compute capacity, storage size, read/write operations (request units or IOPS), data transfer, backups, and multi-region replication. For example, services like Azure Cosmos DB price by throughput (RU/s) or serverless request usage, while others price by instance size plus storage and I/O. Estimate cost by measuring expected document size, read/write rate, indexing needs, and replication requirements.
Category: data
Difficulty: intermediate
Related Terms
See Also