# Document Database

> A NoSQL database that keeps each record as one document. It looks a lot like JSON.

**Field:** Software Development  
**Category:** Databases  
**Also known as:** Document Store, Document-Oriented Database

## Think of it like

Think of it like a folder of filled-in forms. Each form holds all the facts on one thing.

## Definition

A document database stores each record as one document. Documents are usually written like JSON. A document can hold lists and nested parts, so one order can carry all its items inside it. Documents in the same group do not have to share the same fields. You can still search them and build indexes on their fields. It suits data that is read and saved as one whole piece.

## Example

Lucy's shop saves each order as one document, with its items and address inside. Showing an order is one read, with no joins.

## Example code

```json
{
  "_id": 1042,
  "customer": "Lucy",
  "items": [
    { "name": "Mug", "qty": 2 },
    { "name": "Tea", "qty": 1 }
  ]
}
```

One order, with its items kept inside it.

## Why it matters

When you use a record as a whole, keep it in one document. It is simple and fast.

## Common mistake

Copying the same customer into lots of orders. When the customer changes, you must find and fix each copy.

## Three principles

- **One record, one document.** Written like JSON.
- **Nested parts.** Lists live inside the record.
- **Fields can differ.** No fixed schema.

## Related terms

- [NoSQL Database](https://learn.benibix.com/term/development/nosql-database)
- [MongoDB](https://learn.benibix.com/term/development/mongodb)
- [JavaScript Object Notation (JSON)](https://learn.benibix.com/term/development/json)
- [Key-Value Store](https://learn.benibix.com/term/development/key-value-store)

## Told apart from

- [Document Database vs Key-Value Store](https://learn.benibix.com/compare/document-database-vs-key-value-store): People think Redis and MongoDB are the same kind of NoSQL, and they are not. A key-value store keeps one value under each name and finds it only by that name, very fast. A document database keeps whole records, each a JSON-like document, and can search inside them. Redis is often a quick cache. MongoDB is often the main store.

---

Source: https://learn.benibix.com/term/development/document-database
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
