NoSQL Database Types: Key-Value, Document, Graph
On this page
NoSQL: one label, very different databases
"Should we use NoSQL?" is like asking "should we use a vehicle?" Redis, MongoDB, Cassandra and Neo4j are all called NoSQL, and they have almost nothing in common except that they aren't built around tables and joins. The useful question is which access pattern a feature has, because each NoSQL family is designed around one.
The NoSQL database types
Key-value stores (Redis, DynamoDB, Memcached). Give a key, get a value. That's nearly the whole API, which is why they're extremely fast and easy to spread across machines. Great for sessions, caches, counters and rate limits. You can't ask "which sessions belong to users in Berlin?" unless you built a key for that question in advance.
Document stores (MongoDB, Couchbase, Firestore). Each record is a JSON-like document, and documents in one collection can have different fields. Data that's naturally one nested object, like a product with varying attributes or a user profile, is read and written as a unit. Queries on fields and secondary indexes are supported; joins across collections are limited or slow.
Wide-column stores (Cassandra, HBase, Bigtable). Rows are grouped into partitions by a partition key and sorted within the partition. They're built for very high write rates spread across many machines and data centers, with predictable reads by partition key. You design tables around the queries you'll run, often storing the same data several times for different queries.
Graph databases (Neo4j, Amazon Neptune). Nodes and the relationships between them are stored directly, so following connections is cheap. "Friends of friends who like this band" is a few hops of traversal instead of several self-joins.
Search engines (Elasticsearch, OpenSearch) are a fifth family you'll meet in almost every case study. They're built on an inverted index: for every word, a list of the documents that contain it, like the index at the back of a book. A query for "red running shoes" looks up three short lists and intersects them, then ranks the matches by relevance. A relational WHERE name LIKE '%shoe%' can't use a normal index and scans every row. Search engines are usually a secondary copy, fed from the main database, so results lag writes by a second or so.
| Family | Built for | Weak at |
|---|---|---|
| Key-value | Lookups by known key at huge speed | Queries by anything but the key |
| Document | Self-contained, varied records read as a whole | Joins and transactions across documents |
| Wide-column | Massive write volume, multi-region availability | Ad-hoc queries; table design is query-specific |
| Graph | Traversing relationships many hops deep | Bulk aggregation over all records |
| Search | Full-text relevance, typo tolerance, facets | Being the source of truth; transactions |
Worked example: choosing databases for a social app
| Feature | Store | Why |
|---|---|---|
| Sessions, rate-limit counters | Redis | Simple lookups by key, very high rate |
| Profiles with varied attributes | MongoDB | Flexible, nested, read as a unit |
| Activity feed, millions of writes a minute | Cassandra | Write throughput and availability across regions |
| "People you may know" | Neo4j | The query is a relationship traversal |
| Searching posts and people | Elasticsearch | Full-text relevance over millions of documents |
| Accounts, billing, payments | PostgreSQL | Transactions and correctness |
The relational database stays. NoSQL stores are added for specific features whose access pattern it serves poorly. Netflix, for example, uses Cassandra for high-volume data such as viewing history, while relational databases remain common for transactional data.
SQL vs NoSQL: the line is blurrier than it used to be
PostgreSQL has a jsonb type with indexes, so a document-shaped column inside a relational table often covers "we need flexible attributes" without a second database. MongoDB supports multi-document transactions. DynamoDB supports secondary indexes. Start with the access pattern, then check whether a store you already run handles it well enough before adding another one to operate. On Azure, Cosmos DB offers several of these models behind one service: document, key-value, wide-column through a Cassandra-compatible API, and graph through Gremlin. That saves running separate systems, but not designing for each access pattern.
Check yourself
A graph database. The query is a multi-hop traversal of relationships, which graph stores do cheaply and relational databases do with several self-joins.
A leading wildcard can't use a normal index, so every row is scanned. A search engine's inverted index finds matching documents directly and ranks them.
Each table is designed for one query, keyed and sorted for it. Supporting another query efficiently usually means another table with a different partition key.
Not necessarily. A jsonb column in PostgreSQL, with an index on the fields you query, often covers it without adding a new database.
Looking up a value by a known key very fast: sessions, caches, feature flags, rate-limit counters or shopping carts. Key-value stores like Redis and DynamoDB are simple and fast for that pattern, but aren't built for ad-hoc queries across values.