Skip to content
BENIBIX Learn

Document Database

Development🗃️ DatabasesNoSQL Databases

Also known as Document Store, Document-Oriented Database

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

Think of it like

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

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.

Why it matters

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

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 code

json
{
  "_id": 1042,
  "customer": "Lucy",
  "items": [
    { "name": "Mug", "qty": 2 },
    { "name": "Tea", "qty": 1 }
  ]
}
One order, with its items kept inside it.

Common mistake

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

Key takeaways

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

Compare