Kinds of NoSQL
Key-value, document, wide-column, graph.
No SQL isn't one thing. It's a family of four quite different database types. Each is built for a particular shape of data.

- Not one thing
- Four types
- Each for a shape of data
Four types
A key value store is a giant dictionary. Give it a key, get a value, extremely fast. A document store keeps J SON like documents, with flexible fields. A wide column store spreads huge tables across many machines, great for heavy writes. And a graph database stores things and the links between them, like friends of friends.
| Type | Example | Great for |
|---|---|---|
| Key-value | Redis, DynamoDB | sessions, caches |
| Document | MongoDB | flexible records |
| Wide-column | Cassandra | huge write volume |
| Graph | Neo4j | relationships |
A key-value store
A key value store is as simple as a Python dictionary. Put a value under a key. Get it back by its key. Run it. Lookups by key are instant. But notice what's missing. There's no way to ask, which sessions belong to Sam, without scanning everything. You must design your keys around the questions you'll ask.
store = {}
store["session:abc123"] = {"user": "sam", "cart": 2}
store["session:def456"] = {"user": "priya", "cart": 0}
print(store["session:abc123"])
# "Which sessions are Sam's?" means checking every key:
print([k for k, v in store.items() if v["user"] == "sam"]){'user': 'sam', 'cart': 2}
['session:abc123']Summary
Key value stores are fast dictionaries, document stores hold flexible records, wide column stores handle huge writes, and graph databases handle relationships. Next, how databases find rows quickly. Indexes.
Key takeaways- Key-value
- Document
- Wide-column, graph