NoSQL families
NoSQL families
"NoSQL" names several different kinds of database that are not built around relational tables. A key-value store fetches one value by its key, very fast and nothing else. A document store keeps each record as a JSON-like document that can nest lists and objects, so one read returns a whole object. A wide-column store spreads huge, sparse tables across many machines and suits heavy write streams such as events or messages. A graph database stores nodes and the links between them and follows links quickly. Each one gives up some query freedom — ad-hoc joins, transactions across many items — to scale out and stay fast on the queries it was shaped for. NoSQL does not mean no schema, always faster, or no transactions.
- Use when
- Very high request or write rates on a few well-known queries — look up by key, list one owner's items · Data whose shape varies from record to record, read as a whole object · Huge append-heavy streams — events, telemetry, chat messages — read back by key and time · Many-hop relationship questions — friends of friends, fraud rings — for a graph store
- Avoid when
- The queries aren't known yet or keep changing — a relational database answers new questions more easily · The core of the app is many-row, many-table transactions — balances, inventories, orders · The data fits comfortably in one relational database and its replicas — don't pay the modeling cost early
- Trade-offs
- Scale-out and steady latency on designed queries, in exchange for fewer ways to query the data · Schema flexibility moves the schema into the application code — it still exists and still has to be managed · Some stores offer transactions, but they are narrower or cost more than single-item writes · Most real systems end up using more than one store (polyglot persistence) — each adds operations work
- Requires
- Relational databases & indexes
3 objectives · 5 misconceptions
- choose Choose a relational, key-value, document, wide-column or graph store for a workload from how its data is read and written.
- explain Explain what a NoSQL store gives up compared with a relational database — ad-hoc queries, joins, wide transactions — and what it gains.
- predict Predict what happens when an app asks a NoSQL store a question its keys weren't designed for.
- Not true: A NoSQL database has no schema, so you don't have to design your data.
- Not true: NoSQL is always faster than a relational database.
- Not true: NoSQL databases can't do transactions.
- Not true: All NoSQL databases work the same way, so any of them fits any NoSQL job.
- Not true: Relational databases can't handle large-scale apps, so big systems must use NoSQL.
Learn
NoSQL familiesMembers~13 minPractice
No katas practice this yet.