Key-Value and Graph Models
Two models at opposite ends: one that does almost nothing very fast, and one built entirely around following relationships.
Overview
Key-value: doing less on purpose
The interface is three operations:
get(key) -> value
put(key, value)
delete(key)The value is opaque — a blob the store does not interpret. You cannot query by its contents, sort by it, or join on it. There is no schema and no query language.
That poverty is the point. With no query planner, no join algorithms and no secondary indexes to maintain, a lookup is a hash and a read. Redis, Memcached, DynamoDB in its simplest mode and etcd all live here, and they are fast in a way a general-purpose database cannot match, because they have far less to do.
The cost is that every access path must be designed in advance, encoded in the key. Fetching a user by id means user:1234. Fetching them by email means maintaining a second key, email:ada@example.com -> 1234, and keeping the two in step yourself — there is no unique constraint and no transaction spanning them.
The first variant above shows the shape: a two-column table used as nothing but a key lookup.
Where it fits. Caches, sessions, feature flags, rate limiters, leaderboards, service discovery. Anything with one obvious access path and a strong preference for speed.
Where it does not. Anything needing an ad-hoc question. "How many active sessions are from Leeds" is not answerable without scanning every key, which the model is not built for.
Key-Value and Graph Models
Both models, and the SQL equivalents