CSE Roadmap

Core tier · about 2 hours · 5 parts

Part 3 of 5 · 2 min read

The four families, briefly

Document, key-value, graph and column-family stores, each with one line on what it is for.

Think of four different kinds of storage furniture: a filing cabinet with labelled folders, a coat-check counter with numbered tickets, a corkboard with pins and strings connecting notes, and a warehouse shelving system built for scanning one column of barcodes at a time.

In plain words: a document database stores each record as a self-contained document, often JSON, which can have a different shape from record to record. A key-value store maps a single key straight to a value, with no structure the database itself understands. A graph database stores nodes and the relationships between them as first-class data, built for queries that follow connections. A column-family store groups data by column rather than by row, built for writing and scanning huge numbers of rows at once.

A worked example. The bookstore's book reviews, which vary a lot in what fields they include, could fit a document database well. A cache of each customer's current shopping-cart contents fits a key-value store well, since the lookup is always "give me this one customer's cart." A recommendation feature, "customers who bought this book also bought," fits a graph database well, since it is fundamentally about following relationships.

The key lines. A document, shown as JSON, to make the shape-flexibility concrete:

{ "review_id": 501, "book_id": 42, "rating": 5, "tags": ["fast shipping", "great condition"] }

A second review for a different book might have no tags field at all, or an extra verified_purchase field. A relational table with a fixed set of columns cannot vary like this without adding a column for every possible field in advance.

Document store, key-value store, graph database, column-family store

A document store holds self-contained, independently shaped records, usually JSON. A key-value store maps one key directly to one value, with no internal structure the database understands. A graph database stores nodes and their relationships as first-class, queryable data. A column-family store groups and stores data by column, built for fast writes and scans across huge row counts.

Example: the JSON review above belongs to a document store; a cart keyed by customer ID belongs to a key-value store.