# NoSQL Data Models and When to Use Them

> Compare key-value, document, wide-column, graph and time-series stores, and learn to pick a data store from access patterns rather than hype. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/system-design/nosql-data-models
Last updated: 2026-11-28

Compare key-value, document, wide-column, graph and time-series stores, and learn to pick a data store from access patterns rather than hype.

Intermediate · about 4 hours · difficulty 3/5

Learn first: [Relational Databases and SQL for Design](https://www.internhack.in/roadmaps/tracks/system-design/relational-databases)

"NoSQL" covers several very different families. Each trades some relational features for scale, flexibility or speed on a particular access pattern.

### The families

- **Key-value** (Redis, DynamoDB, etcd): get and put by key. Extremely fast and easy to scale. Sessions, carts, feature flags, counters.
- **Document** (MongoDB, Couchbase): JSON-like documents with flexible fields. Good for product catalogues and user profiles that vary in shape.
- **Wide-column** (Cassandra, ScyllaDB, HBase, Bigtable): rows grouped by a partition key, sorted by clustering key. Built for huge write volumes: chat messages, IoT data, activity logs. Discord moved billions of messages to this model.
- **Graph** (Neo4j, Neptune): nodes and edges with fast traversals. Friend-of-friend recommendations, fraud rings.
- **Time-series** (InfluxDB, TimescaleDB, Prometheus): append-heavy metrics with time-based queries and downsampling.
- **Search engines** (Elasticsearch, OpenSearch): inverted indexes for full-text search and filters.

### Design from access patterns

In relational design you model entities first and query later. In most NoSQL stores you **list the queries first** and shape tables to answer each one with a single key lookup or partition scan. Joins usually move into the application or are avoided by duplicating data.

### Choosing in practice

Start with: Do I need multi-row transactions and ad hoc queries? (Relational.) Is the write volume massive and the query pattern fixed? (Wide-column.) Is it a simple lookup by ID at very high QPS? (Key-value.) Many real systems use **polyglot persistence**: Postgres for orders, Redis for sessions, Elasticsearch for search, S3 for images.

### Pitfalls

- Choosing MongoDB to avoid "designing a schema"; the schema just moves into code.
- Picking a bad partition key in Cassandra or DynamoDB and creating hot partitions.

You are ready to move on when you can map five features of a food delivery app to a store type and justify each choice from its access pattern.

## Key concepts

- **Key-value stores**
- **Document databases**
- **Wide-column stores**
- **Graph databases**
- **Time-series databases**
- **Search engines (inverted index)**
- **Access-pattern driven modelling**
- **Polyglot persistence**

## Mini project

Design the tables for a chat app's messages in both PostgreSQL and Cassandra (or DynamoDB). For each, write the three main queries and explain which store handles 1 lakh writes per second more easily and why.

## Check yourself

Why do wide-column databases ask you to design tables around queries instead of entities?

## Free resources

- [MongoDB manual](https://www.mongodb.com/docs/manual/) (MongoDB)
- [Apache Cassandra documentation](https://cassandra.apache.org/doc/latest/) (Apache)
- [What is Amazon DynamoDB?](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Introduction.html) (AWS)
- [How Discord stores trillions of messages](https://discord.com/blog/how-discord-stores-trillions-of-messages) (Discord)

Previous: [Relational Databases and SQL for Design](https://www.internhack.in/roadmaps/tracks/system-design/relational-databases) · Next: [Indexes and Storage Engines](https://www.internhack.in/roadmaps/tracks/system-design/indexing)

## More in Data Storage and Databases

- [Relational Databases and SQL for Design](https://www.internhack.in/roadmaps/tracks/system-design/relational-databases)
- [NoSQL Data Models and When to Use Them](https://www.internhack.in/roadmaps/tracks/system-design/nosql-data-models)
- [Indexes and Storage Engines](https://www.internhack.in/roadmaps/tracks/system-design/indexing)
- [Replication](https://www.internhack.in/roadmaps/tracks/system-design/replication)
- [Sharding and Partitioning](https://www.internhack.in/roadmaps/tracks/system-design/sharding-partitioning)
- [Consistency Models, CAP and PACELC](https://www.internhack.in/roadmaps/tracks/system-design/consistency-cap-pacelc)
- [Object Storage and Large Files](https://www.internhack.in/roadmaps/tracks/system-design/object-storage)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [System Design Roadmap](https://www.internhack.in/roadmaps/tracks/system-design)
