Database types you should know
A field guide to the eight database families and when each one wins.
There is no universal database — each family optimizes for a different data model and access pattern. Relational, key-value, document, wide-column, graph, time-series, search, and vector databases each trade off structure, scale, and query power differently. Knowing the eight lets you pick the right tool, or combine several (polyglot persistence) in one system.
Relational
Relational databases store data as rows in tables with a fixed schema, and use SQL to join tables and enforce constraints. They guarantee ACID transactions, making them the trustworthy default for structured, interrelated data like orders, users, and payments. Reach for them (PostgreSQL, MySQL) whenever relationships and correctness matter and your schema is reasonably well defined.
Key-value
Key-value stores map a unique key directly to a value, giving the simplest and fastest possible lookups. With no query language or joins, they excel at caching, session storage, and any workload where you fetch by a known key. Redis and DynamoDB are common choices when raw speed and simple access beat rich querying.
Document
Document databases store JSON-like documents grouped into collections, with a flexible schema so each record can carry a different shape. They fit nested, self-contained objects that evolve quickly — user profiles, catalogs, content — read and written as a whole. MongoDB is the archetype when your data maps naturally onto documents rather than normalized tables.
Wide-column
Wide-column stores organize data by row key into column families, where each row can have a different, sparse set of columns. This layout is built for enormous write throughput and horizontal scale across many nodes. Cassandra and HBase power workloads like event logging, messaging, and time-ordered feeds where writes are relentless and queries are known in advance.
Graph
Graph databases model data as nodes and the edges between them, treating relationships as first-class citizens. They make traversing connections — friends-of-friends, dependency chains, fraud rings — fast and expressive, where the same query would need many painful joins in SQL. Neo4j is the classic choice when the relationships between entities are the main thing you query.
Time-series
Time-series databases are optimized for data points stamped with time — metrics, sensor readings, financial ticks — that arrive in high volume and are queried over time ranges. They compress timestamped data efficiently and accelerate windowed aggregations like averages per minute. InfluxDB and TimescaleDB suit monitoring, IoT, and observability workloads.
Search
Search engines index text (and structured fields) into inverted indexes so full-text queries return ranked, relevant results in milliseconds. They handle fuzzy matching, relevance scoring, faceting, and aggregations that a plain database cannot do well. Elasticsearch and OpenSearch power product search, log analytics, and any feature that needs 'find the most relevant matches.'
Vector
Vector databases store high-dimensional embeddings and find the nearest ones by similarity rather than exact match. They power semantic search, recommendations, and retrieval-augmented generation for AI, where 'closest in meaning' matters more than 'equal.' Pinecone, Milvus, and the pgvector extension serve these embedding-driven workloads.
Why there are so many kinds of database
For a long time "database" meant one thing: a relational, SQL database. It is still the most important and most common kind, but the last two decades produced an explosion of specialized databases, and the reason is simple: there is no single data model that is optimal for every workload. A relational database is superb at structured, related data with strong consistency, but it is a poor fit for storing billions of time-stamped sensor readings, or for finding the most relevant documents for a search box, or for traversing a social graph six hops deep.
Each database family makes a deliberate bet — it optimizes its storage layout, indexing, and query engine for one shape of data and one style of access, accepting that it will be mediocre at others. Understanding the families is therefore less about memorizing product names and more about recognizing which shape your data and queries take, so you can reach for the tool built for that shape. Modern systems increasingly use several at once — a practice called polyglot persistence — rather than contorting one database to do everything.
Relational and key-value — the two poles
Relational databases (PostgreSQL, MySQL) are the structured, disciplined end of the spectrum. Data lives in tables of rows and columns with a defined schema; SQL lets you join tables to answer questions that span entities, and ACID transactions guarantee correctness under concurrency. This makes them the right default for the core of most applications — anything with clear relationships and a need for integrity, like accounts, orders, and inventory. The cost is that the schema is comparatively rigid and scaling writes beyond one machine takes real effort.
Key-value stores (Redis, DynamoDB) sit at the opposite pole of simplicity. They map a unique key to an opaque value and do essentially nothing else — no joins, often no query language. That radical minimalism buys extreme speed and easy horizontal scaling, which is exactly what you want for caching, session storage, feature flags, and any access pattern where you already know the key you want. What you give up is the ability to query *by the value* or express relationships; the store neither knows nor cares what is inside the value.
Document and wide-column — flexible and huge
Document databases (MongoDB) store JSON-like documents with a flexible schema, letting each record carry its own nested shape. They shine when data is naturally hierarchical and read or written as a whole object — user profiles, product catalogs, CMS content, event payloads — and when the schema is still evolving, since adding a field needs no migration. The trade is that heavily relational data with many cross-references becomes awkward, pushing join logic into the application.
Wide-column stores (Cassandra, HBase) look superficially table-like but work very differently. Data is organized by a row key into column families, and each row can hold a different, sparse set of columns — a row might have millions of columns or three. This layout is engineered for massive write throughput and near-linear horizontal scale across many nodes, with no single point of failure. The catch is that you must design your tables around your queries up front, because ad-hoc joins and flexible querying are not on offer. They power relentless write workloads: activity feeds, messaging, sensor ingestion, and time-ordered event logs at internet scale.
Graph and time-series — specialized shapes
Graph databases (Neo4j) make relationships the star. Data is stored as nodes connected by edges, and the engine is optimized to traverse those connections quickly. Questions that are painful in SQL — "who are the friends of my friends who also like jazz," "what depends on this failing service," "which accounts form a fraud ring" — become natural, efficient traversals. When the connections between entities are the primary thing you query, a graph database can be orders of magnitude clearer and faster than repeated joins.
Time-series databases (InfluxDB, TimescaleDB) specialize in data indexed by time: metrics, sensor readings, stock ticks, application telemetry. This data arrives in enormous volume, is almost always append-only, and is queried over time ranges with aggregations ("average CPU per minute over the last day"). Time-series engines exploit those patterns with time-partitioned storage, aggressive compression of timestamped points, and fast windowed rollups. They are the backbone of monitoring, observability, IoT, and financial analytics — anywhere the question is fundamentally "how did this value change over time?"
Search and vector — finding, not just fetching
The last two families are about finding relevant data rather than fetching known records. Search engines (Elasticsearch, OpenSearch) build an inverted index that maps each term to the documents containing it, enabling fast full-text search with relevance ranking, fuzzy matching, faceting, and aggregations. They answer "show me the best matches for these words," which a relational LIKE query does poorly. They power site search, product search, and log analytics — often running alongside a primary database that remains the system of record.
Vector databases (Pinecone, Milvus, or Postgres with pgvector) are the newest family, driven by AI. They store high-dimensional embeddings — numeric representations of meaning produced by machine-learning models — and retrieve the nearest neighbors by similarity rather than exact match. This is what makes semantic search ("find things that *mean* the same"), recommendations, and retrieval-augmented generation (RAG) possible: given a query embedding, the database returns the closest stored vectors in meaning-space.
Choosing and combining them
With eight families in view, selection becomes a matter of matching shape to job. Start from your data and access patterns, not from a favorite product:
- Structured, related data needing integrity → relational.
- Simple, fast lookups by known key → key-value.
- Nested, evolving objects read as a whole → document.
- Relentless writes at massive scale → wide-column.
- Deeply connected data queried by relationship → graph.
- High-volume timestamped measurements → time-series.
- Ranked full-text or fuzzy search → search.
- Similarity over embeddings for AI → vector.
Crucially, these are not mutually exclusive. A single real product might keep its core data in PostgreSQL, cache hot reads in Redis, power its search box with Elasticsearch, and back its AI features with a vector index — this is polyglot persistence, using the right store for each job. The mark of good judgment is neither forcing everything into one database nor adding a new one for every whim, but recognizing when a workload's shape genuinely calls for a specialist, and reaching for it deliberately.
Relational: rows and tables with strict schema and SQL joins — the default for structured, related data.
Key-value: a simple key-to-value dictionary — fastest lookups, ideal for caching and sessions.
Document: JSON-like documents with flexible schema — great for nested, evolving objects.
Wide-column: sparse rows keyed by row and column families — built for massive write-heavy scale.
Graph, time-series, search, and vector databases each specialize in relationships, time-stamped metrics, text search, and similarity respectively.
Real systems often mix several (polyglot persistence) rather than forcing one database to do everything.
Quick quiz
Which database family treats relationships between entities as first-class and makes multi-hop traversals fast?
You need semantic search over text embeddings for a RAG pipeline. Which database type fits?
PostgreSQL 101
The relational database that quietly became everyone's default.
How MongoDB works
A database that stores JSON-like documents instead of rows and tables.
Comparing key-value stores
Four stores that all map keys to values — and almost nothing else in common.
Which database should I use on AWS
Seven managed engines, one rule — match the database to the shape of your data and access pattern.