Skip to content
BENIBIX Learn

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.

Development🗃️ Databases

Document Database

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

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.
Why it matters
When you use a record as a whole, keep it in one document. It is simple and fast.
Full entry
Development🗃️ Databases

Key-Value Store

The simplest NoSQL database. You save a value under a key and read it back.

A key-value store is the simplest kind of NoSQL database. It saves each value under a unique key, like a name tag, and gets it back by that key. It does not look inside the value, so it cannot search by what the value holds. That makes it very fast for simple saves and reads. It is often used for caches, sessions and counters.

Example
Emma's site keeps each logged-in user's session in a key-value store. The key is the session id, and the value is who they are.
Why it matters
When you only ever look things up by one key, nothing is faster or simpler.
Full entry

In one line

Document Database
A NoSQL database that keeps each record as one document. It looks a lot like JSON.
Key-Value Store
The simplest NoSQL database. You save a value under a key and read it back.