Advanced Topic 40 of 51 Databases
Document Stores
Databases holding JSON-like documents.
How it works
Document databases store records as self-contained documents, usually JSON or BSON, which can have nested fields and arrays and vary in structure. Documents are grouped into collections and retrieved by id or by queries and secondary indexes. Related data is often embedded in one document to avoid joins, so reading an object takes a single lookup. MongoDB, Couchbase and Firestore are common examples.
Step-by-step walkthrough
- A document holds nested JSON.
- The customer details are inside it.
- The items are an array in the same document.
- One read returns the whole order, with no joins.
- Schemas are flexible, but consistency across documents is your job.
Where it is used
Product catalogs, user profiles, content management, event data and applications whose records have varying fields fit document stores well.
Common pitfall
Embedding data duplicates information and updates can be awkward when it changes in many places. Unbounded arrays make documents huge. Joins are limited or slow, and multi-document transactions are costlier. Model according to read patterns, decide when to reference instead of embed and enforce validation rules with schema validation.
Where it fits in the course
Document Stores is topic 40 of 51 in Databases, rated Advanced. It follows NoSQL Databases. The next topic is Key-Value Stores.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Databases quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Databases quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Document Stores?
Where do people use Document Stores?
What is the most common mistake with Document Stores?
What should I learn before this topic?
How can I practice it?
Is Document Stores hard to learn?
How long does it take to learn Document Stores?
Which topics are related to Document Stores?
What should I study after Document Stores?
Related topics
- NoSQL Databases (Databases)
- Key-Value Stores (Databases)
- Sharding (Databases)
- Column-Family Stores (Databases)