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.
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.
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.
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.