NoSQL · Map

Choosing a Database

There is no best database, only a best fit for an access pattern. This page maps the eight families, from relational to vector, compares what each gives and takes, offers a decision guide by the way the data is read and written, previews polyglot persistence, and lays out the pages that follow.

8
Families
10
Access patterns
7
Pages planned
5
Questions to choose
01
Chapter One - The Map

The Database Families

"NoSQL" is a crowd, not a category. A more useful way to read the landscape is by data model: what is the shape of the thing you store, and what questions do you ask of it? Each family below is optimised for one shape and answers some questions superbly and others poorly.

Eight families of databases, by the shape of the data
Relational tables, rows, SQL PostgreSQL, MySQL Key-value key to opaque value Redis, DynamoDB Document JSON-like documents MongoDB, Couchbase Wide-column partition + sorted rows Cassandra, HBase Graph nodes and edges Neo4j, Amazon Neptune Search inverted index Elasticsearch, OpenSearch Time-series timestamped points InfluxDB, TimescaleDB Vector embeddings, similarity Milvus, Qdrant, pgvector Most real systems use one relational database plus one or two of the others, each for a specific job.
FamilyData modelWhat it is forRepresentative products
RelationalTables of rows with a schema, related by keysStructured business data, ad-hoc queries, joins, transactions, constraints. The default system of recordPostgreSQL, MySQL, Oracle Database, Microsoft SQL Server
Key-valueA key mapped to an opaque valueLookups by a known key at very high rates; caches, sessions, counters, leaderboards, shopping cartsRedis, Memcached, Amazon DynamoDB, etcd
DocumentSelf-describing JSON-like documents, queryable by fieldRecords whose shape varies, read and written as a whole: catalogues, profiles, contentMongoDB, Couchbase, Google Cloud Firestore, Amazon DynamoDB (also key-value)
Wide-columnRows grouped by partition key, with many sparse columns, sorted within the partitionMassive write volumes, known access paths, time-ordered data per entity across data centresApache Cassandra, ScyllaDB, Apache HBase, Google Cloud Bigtable
GraphNodes, relationships and propertiesQueries about connections: friends of friends, fraud rings, recommendations, dependency graphsNeo4j, Amazon Neptune
SearchDocuments with an inverted index and relevance scoringFull-text search, filtering and faceting, log analyticsElasticsearch, OpenSearch, Apache Solr
Time-seriesPoints keyed by time, with tags and valuesMetrics, sensor and event data with retention and downsamplingInfluxDB, TimescaleDB, Prometheus (monitoring)
VectorHigh-dimensional embeddings with an approximate nearest-neighbour indexSimilarity search: semantic search, recommendations, retrieval for AI applicationsMilvus, Qdrant, Pinecone, Weaviate, PostgreSQL with the pgvector extension

Boundaries are blurry on purpose. PostgreSQL stores JSON documents and, with extensions, vectors and time-series; MongoDB supports multi-document transactions; DynamoDB is both key-value and document; Elasticsearch is used as a document store. A product belongs to the family it is best at, not the only one it can imitate.

Key insight: Do not ask "which database is best?" Ask "what is the dominant access pattern for this data?" and pick the family whose strength that is. The next chapters give you the questions.
02
Chapter Two - Trade-offs

What Each Family Gives and Takes

The table is a generalisation: individual products differ and configuration moves the dots. Use it to build intuition, then check the specific product.

Query powerScales outTypical consistencyTransactionsSchema
RelationalHighest: SQL, joins, aggregates, ad-hocReads easily; writes need sharding workStrong (single node or primary)Full ACID, multi-rowEnforced
Key-valueLowest: get/put by key (plus structure operations in Redis)Very wellTunable, from eventual to strongSingle key; limited multi-keyNone
DocumentGood: queries and indexes on fields, aggregation pipelinesWell (sharding)TunableSingle document; multi-document in someFlexible, optionally validated
Wide-columnNarrow: by partition key and sort range; designed per queryExcellentTunable (quorums)Single partition, lightweightColumn families
GraphExcellent for traversals, weak for bulk analyticsHarder (graph partitioning is difficult)Often strongUsually ACID on one clusterFlexible
SearchExcellent for text and filters; not for transactionsWell (shards)Near-real-time: new data appears after a refreshNoneMappings
Time-seriesTime-range scans and aggregatesVariesVariesLimitedTags + fields
VectorSimilarity (approximate); usually metadata filters tooVariesVariesUsually noneVectors + metadata

Three things recur. Query flexibility falls as scale-out rises. Tunable consistency means you pay latency for stronger reads, the PACELC trade covered in 01 NoSQL Fundamentals. Search and vector stores are almost always a secondary copy: the truth lives elsewhere and the index is rebuilt from it.

⚠ Using a search index as the system of record
  • Elasticsearch is excellent at finding documents and not designed to be the only home for data that must never be lost or must be strongly consistent. Keep the source of truth in a database and treat the index as a derived, rebuildable view.
03
Chapter Three - Decide

A Decision Guide by Access Pattern

Start from how the data is read and written, not from the technology. For each pattern, the table names the family that is built for it and the usual trap.

Pick by access pattern
Dominant access patternReach forBecauseTrap
Point lookup by a known key, huge rate, low latencyKey-value (Redis, DynamoDB) or a cache in front of the databaseOne key, one machine, no planningCannot ask "all items where..." without a second index or copy
Range scan in key order ("orders of customer 42 since Monday")Wide-column, DynamoDB sort key, or a relational indexData stored sorted inside a partitionA range across partitions is a scatter; choose the partition key carefully
Ad-hoc queries nobody planned in advanceRelationalSQL and a query planner exist for thisChoosing NoSQL early forces you to know the questions up front
Joins across several entitiesRelationalJoins are native and indexedDenormalising in NoSQL moves the join into your writes
Documents read and written whole, shape variesDocument store (MongoDB, Couchbase)One read returns the whole aggregateUnbounded arrays and huge documents
Full-text search, relevance, facetsSearch engine (Elasticsearch, OpenSearch)Inverted index and scoringTreating it as the source of truth; eventual (refresh) visibility
Aggregation over large volumesColumnar warehouse or relational database; some document stores for modest volumesScans over columnsKey-value stores cannot aggregate; scanning one costs time and money
Graph traversal (depth, paths, neighbours of neighbours)Graph database (Neo4j, Neptune)Following edges is cheap; multi-hop joins in SQL get slow and awkwardUsing a graph database for data with few relationships
Time series: append-heavy, time-range queries, retentionTime-series database; or partitioned relational tables; or wide-column keyed by (entity, time bucket)Compression, downsampling, expiry by timeHigh-cardinality tags can overwhelm the index
Similarity search over embeddingsVector index (Milvus, Qdrant, pgvector, ...)Approximate nearest-neighbour indexApproximate results; the embedding model, not the database, decides quality
Five questions that settle most choices
  • What are the top three queries, exactly, with their rates?
  • How big will the data be in a year, and how fast does it grow?
  • What consistency does each piece of data need? (Money and stock: strong. Likes and views: eventual.)
  • Do we need joins, transactions or ad-hoc reporting? (If yes, start relational.)
  • Who will operate it? A managed service is a feature; an unfamiliar cluster at 3 a.m. is a risk.

If after those questions the answer is still "relational", that is a perfectly good answer. Modern PostgreSQL and MySQL cover documents (JSON columns), full-text search, time-series (with extensions) and vectors (pgvector) well enough for many workloads, and one database is far easier to run than four.

04
Chapter Four - Polyglot Preview

More Than One Database, On Purpose

Polyglot persistence means using several database types in one system, each for the job it does best. A typical shop keeps orders in PostgreSQL, product search in Elasticsearch, sessions and hot product data in Redis, and clickstream in a warehouse. Page 07 treats this in depth; this is the preview.

Polyglot persistence: one source of truth, several derived stores
Order service PostgreSQL source of truth orders, payments writes Event log / outbox changes as events publish Redis cache, sessions Elasticsearch search index Warehouse / lake reports, analytics The database of record is written first; every other store is fed from it and can be rebuilt. Each store is chosen for one access pattern. Order is kept per key, and consumers are idempotent.
RuleWhy
One system of record per factIf two stores can both be edited independently, they will disagree and nobody knows which is right
Derived stores are fed from the record, asynchronouslyThrough change events or an outbox, not by writing to everything from the request handler (the dual-write problem; see Event-Driven Patterns)
Every derived store is rebuildableIf the index or cache is lost, you can replay from the source
Accept lag, and show itThe search index may be seconds behind; design screens so that does not hurt (read-your-writes where it matters)
Add a store only for a measured needEach one is more to patch, back up, monitor, secure and learn
⚠ Collecting databases like badges
  • A team adds Redis, Mongo, Elasticsearch and Cassandra to a system that served 50 requests per second from PostgreSQL. Now there are four failure modes, four upgrade paths, four sets of credentials, and five ways for data to disagree. The cost of each extra store is paid every week, forever.
05
Chapter Five - Neighbours

How This Section Relates to SQL and to Caching

The SQL section

This section assumes you know the relational basics, which the SQL guide teaches: tables, joins, indexes, transactions and schema design. Everything here is easier if you can say what the relational answer would be first. A few places they meet directly:

TopicIn SQLIn this section
IndexesIndexes and performanceSecondary indexes in a partitioned store (fundamentals, chapter 7)
Schema designSchema designModelling from queries, denormalisation, embedding or referencing (fundamentals, chapter 8)
TransactionsACID in a single databaseWhat is lost and regained: single-item atomicity, conditional writes (fundamentals, chapter 9)
Joins and aggregationJoining tables, AggregationReplaced by precomputed shapes, or by a search or warehouse store
Caching

A cache is not a database family but a role: a fast, disposable copy of data that lives elsewhere. Redis and Memcached are used for it. Caching is the first scaling step before any change of database: if most reads hit the same few thousand items, a cache can remove much of the load from your primary store with no remodelling. Page 06 covers cache-aside, write-through, invalidation and stampedes; the Spring side is in Spring: Caching and Resilience.

A cache is...A database is...
Disposable: losing it costs speed, not dataDurable: the record of truth
Filled on demand, expired by time or by eventWritten by the business transaction
Allowed to be stale within a stated limitExpected to be correct
Scaling order of operations
  • First measure and fix queries and indexes in the existing database.
  • Then add a cache or read replicas for read-heavy traffic.
  • Then partition or move one specific workload to a family built for it (a key-value store for sessions, a search engine for search).
  • Only then consider moving the system of record, and do it by the strangler approach in fundamentals chapter 10.
06
Chapter Six - The Learning Path

Pages in This Section

Read Fundamentals first: every later page leans on its vocabulary (partition key, quorum, eventual consistency). After that, take the pages in the order your project needs.

  • 01 · NoSQL Fundamentals - CAP and PACELC, consistency, replication and quorums, partitioning, secondary indexes, modelling, with a plain-Java quorum simulation
  • 02 · Redis - data structures, persistence, replication, cluster, caching and beyond
  • 03 · DynamoDB - partition and sort keys, indexes, capacity modes, single-table design, transactions
  • 04 · MongoDB - documents, indexes, aggregation, replica sets and sharding, schema design
  • 05 · Elasticsearch - inverted indexes, mappings, queries, relevance, shards, operations
  • 06 · Caching Patterns - cache-aside, write-through, invalidation, stampedes, TTLs, consistency with the database
  • 07 · Polyglot Persistence - combining stores safely: source of truth, derived views, synchronisation, failure modes
Related sections
  • SQL Guide - the relational foundation, schema design and indexes.
  • Messaging - events and outbox patterns that keep derived stores in sync.
  • Spring Guide - Spring Data and caching on the application side.
  • Performance Engineering - measurement and database limits that decide when to scale.
07
Chapter Seven - Summary

Cheat Sheet and Recap

Cheat sheet
If the dominant need is...Start withWatch out for
Known-key lookups at huge scaleKey-value (Redis, DynamoDB)No ad-hoc queries
Whole documents of varying shapeDocument store (MongoDB)Unbounded arrays, schema drift
Huge write volume with known queriesWide-column (Cassandra) or DynamoDBHot partitions, query-first design
Ad-hoc queries, joins, transactionsRelational (PostgreSQL, MySQL)Nothing: this is the default
Full-text and facetsElasticsearch or OpenSearchNot a source of truth
Multi-hop relationshipsGraph (Neo4j, Neptune)Few relationships means little benefit
Metrics and sensor dataTime-series databaseHigh-cardinality tags
Semantic similarityVector index (pgvector, Milvus, Qdrant)Approximate results
Speed up reads on any storeCache (Redis)Invalidation and stampedes
∑ The database map - what to remember
  • Pick by access pattern, not by brand or by what is popular.
  • Relational is the default system of record; add other families for a named, measured need.
  • Every family trades query power for scale or speed. Ask what you are giving up.
  • Search, cache and vector stores are derived copies. Keep one source of truth and make the rest rebuildable.
  • A cache comes before a new database, and measuring comes before both.
  • Each extra store is permanent operational cost: patches, backups, monitoring, skills.
Version note

Product names and families on this page are given for category only; no limits, defaults or prices are quoted, so nothing here is version-sensitive. Check each product's documentation for the version you will run.

Next in this section
  • 01 NoSQL Fundamentals - CAP, consistency, replication, partitioning and modelling, with a plain-Java quorum simulation.
  • SQL Guide - revisit the relational baseline before choosing a different model.