SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
  • Relational Databases
  • Document Databases
  • Key-Value Databases
  • Full-Text Search Engines
  • Wide Column Databases
  • Time Series Databases
  • Graph Databases
  • Vector Databases
  • NewSQL Databases
  • Columnar Databases
  • In-Memory Databases
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Data and Storage/Database Types (Deep Dive)

Wide Column Databases

Rows with flexible columns, spread over many machines, built for huge writes (Cassandra, Bigtable).

⏱ 13 min readAdvancedInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

A wide-column database stores data in tables, but spreads each table over many machines and is built for huge write volumes. Apache Cassandra, Google Bigtable, HBase and ScyllaDB are the well-known ones.

  • The partition key decides which machine holds a row.
  • The clustering key decides the sort order inside that partition.
  • Rows in the same table can have different columns, and you design tables around your queries, not around the data.

02Concept: What is it?

Picture a table that is too big for one computer. You must cut it into pieces. A wide-column database cuts it by the partition key. All rows with the same partition key stay together, in one partition. The key is hashed, and the hash picks the machine. Reads and writes for one key go to one place (and its replicas).

Inside a partition, rows are kept sorted by the clustering key. So "give me sensor s2 for Tuesday" is a read of one neat, contiguous slice. Writes are cheap because the engine appends them to a log and to memory first (an LSM tree, see that topic) and sorts later.

Partition key and clustering key
Partition key: sensor_id
🧱s1Node A
🧱s2Node B
🧱s3Node C
→↓open partition s2
Clustering key: day, time (sorted)
Mon 08:00 → 21.5
Mon 08:05 → 21.7
Tue 08:00 → 22.1
Tue 08:05 → 22.4
Primary key ((sensor_id), day, time): sensor_id picks the machine, day and time sort the rows inside.
🧠Query first, table second
In SQL you design tables from the data, then write any query. Here you list your queries first, then build one table per query. Data is often copied between tables on purpose.

03Real-Life Example

🍵The Filing Warehouse
A huge warehouse has many rooms. A rule says that all papers of one customer go to the room given by the customer number (the partition key). Inside the room, the papers lie in date order (the clustering key). To find "customer 7, March", you walk to one room and open one stack. To find "everyone who ordered a lamp", you must visit every room. That is why the warehouse is built for the questions you plan, and why new questions may need a second copy of the papers filed a different way.
Warehouse
Wide-column database
The rule that sends papers to a room
Hash of the partition key
One room
A node (holding many partitions)
One customer's stack of papers
A partition
Papers in date order
Clustering key (sort order)
Each paper may have different boxes filled
Flexible columns
Duplicate files for another question
A second table, one per query
Rooms are copied to other buildings
Replication
Visiting every room to answer an odd question
Full scan, a query that does not fit
A write path built for speed
✍️Write
→↓append
📜Commit logdisk, sequential
→↓
🧠Memtablesorted, in memory
→↓flush when full
💾SSTableimmutable file

04Why Do We Need It?

✍️Huge write speed
Writes are appended to a log and a memory table. No random disk seeks.
📈Scale by adding nodes
Every node is equal. More nodes means more storage and throughput.
🛡️No single point of failure
Cassandra has no primary node. Data is replicated, and any replica can serve.
🌍Multi-region
Replicas can live in several data centres, close to users.
🔧Tunable consistency
You choose, per query, how many replicas must answer (ONE, QUORUM, ALL).
🧮Predictable reads
A query with the partition key goes to a few known nodes and reads a sorted slice.
Pay the design effort up front (know your queries), and get writes and reads that stay fast at any size.

05Where Do We Use It?

📡IoT and time series
Sensor readings arriving all day, read back by device and time range.
💬Messaging and feeds
Messages per conversation, ordered by time.
📜Event and audit logs
Append-heavy data that is rarely updated.
👁️Activity tracking
Views, clicks and watch history per user.
🧾Order history, user timelines
Everything for one user, newest first.
📊Large analytics stores
Bigtable-style tables behind Google services and Hadoop-era systems (HBase).

06Types / Parts / How It Works

Parts of the data model

PartWhat it doesExample
Partition keyHashed to choose the node. Same key, same partition.sensor_id
Clustering keySorts rows within a partition. Allows range reads.day, time (ASC or DESC)
Primary keyPartition key plus clustering columns. Must be unique.((sensor_id), day, time)
Regular columnsThe data. Different rows can use different columns.temp, battery
KeyspaceA group of tables with a replication setting.RF = 3 in two data centres
TTLOptional expiry per value, so old data deletes itself.TTL 30 days

Which queries fit?

QueryFits?Why
Partition key = valueYesGoes to one set of replicas.
Partition key + range on the clustering keyYesA contiguous sorted slice.
Only a clustering column, no partition keyNoMust contact every node.
Filter on a normal columnNoNothing is sorted by it. Scan, or use a second table or index.
Join, or GROUP BY across partitionsNoNot supported. Pre-compute or use Spark.
Cassandra / ScyllaDB
Peer to peer
  • No primary node
  • Tunable consistency
  • CQL, SQL-like language
  • Great for multi-region writes
Bigtable / HBase
Master and tablet servers
  • Rows sorted by row key
  • Rows split into tablets or regions
  • Strong consistency per row
  • Data lives in a distributed file system
Replication with a token ring
🧑‍💻Client
→↓any node
🧭Coordinatorhash(key) → replicas
↔QUORUM = 2 of 3
🧱Replica 1
🧱Replica 2
🧱Replica 3
Routing Copies of one partition
With replication factor 3, each partition is stored on three nodes. Any of them can answer.
VisualizerPartition key and clustering key: which queries fit?Pick each query in turn and watch which nodes and partitions are touched. Try the queries without the partition key, and drag the row count up.
Table: readings, primary key ((sensor_id), day, time)
SELECT * FROM readings WHERE sensor_id = 's2' AND day = 'Tue'
Allow filtering (only matters for bad queries)
Partitions (one per sensor_id), placed on 3 nodes. Inside each, rows are sorted by day, then time. Bright = read by the query.
Node 1
partition sensor_id = s1
Mon
Tue
Wed
partition sensor_id = s4
Mon
Tue
Wed
Node 2
partition sensor_id = s2
Mon
Tue
Wed
Node 3
partition sensor_id = s3
Mon
Tue
Wed
Nodes contacted
1
Partitions read
1
of 4
Rows read
24
of 288 stored
Query fits the table?
Yes
The partition key (sensor_id) is given, so the database goes to ONE machine. Rows are stored sorted by day, so Tue is a contiguous slice that can be read in one sequential pass.

A simplified model. The nodes are placed by a fixed rule here (real Cassandra hashes the partition key onto a token ring). The row counts are exact for this layout. The lesson: you design the table around the query, and a query that does not name the partition key does not fit.

07How to Use It / Steps / Implementation

Modelling data in Cassandra style

  1. 1
    Write down the queries first
    For example: latest 50 messages in a chat, readings of a sensor for a day.
  2. 2
    Choose the partition key
    It must be in every query, and it must spread data evenly over many values.
  3. 3
    Choose clustering columns
    They define the sort order and the range you can read. Put the most-used sort first.
  4. 4
    Keep partitions a sensible size
    A common rule of thumb is to stay well below about 100 MB per partition. Add a time bucket to the key if a partition would grow forever.
  5. 5
    One table per query
    If you need the same data another way, write it to a second table. Writes are cheap, so copying is the norm.
  6. 6
    Pick the consistency level
    QUORUM for reads and writes gives strong results when replicas are healthy. ONE gives speed and availability.
  7. 7
    Use TTL and avoid deletes
    Deletes leave markers called tombstones. Expiring by TTL on time-bucketed partitions is gentler.
CQL (Cassandra Query Language)
CREATE TABLE readings (
  sensor_id  text,
  day        date,
  time       time,
  temp       double,
  PRIMARY KEY ((sensor_id, day), time)
) WITH CLUSTERING ORDER BY (time DESC);

-- one partition per sensor per day: bounded size
SELECT * FROM readings
WHERE sensor_id = 's2' AND day = '2026-12-02' LIMIT 50;
💡Bucket your partitions
Putting the date in the partition key (as above) caps how big one partition can get, and spreads a busy sensor over time. It costs a little: a query for a week reads 7 partitions.

08Key Terms to Know

TermMeaning in easy words
PartitionAll rows that share a partition key, stored together on the same replicas
Partition keyThe part of the primary key that is hashed to pick the node
Clustering keyThe part of the primary key that sorts rows inside a partition
Wide rowA partition holding many rows or columns, a good fit for a time series
Column family / tableA named group of rows. Bigtable says column family, Cassandra says table
Replication factor (RF)How many copies of each partition exist
Consistency levelHow many replicas must answer a read or write (ONE, QUORUM, ALL)
Memtable / SSTableA sorted in-memory table / an immutable sorted file on disk
CompactionMerging SSTables in the background to remove old versions
TombstoneA marker that says a value was deleted. It is cleaned up later
Hot partitionOne partition that gets far more traffic or data than others
GossipHow Cassandra nodes tell each other who is alive

09Pros, Cons and Trade-offs

✅ Pros
  • Very high write throughput
  • Scales out linearly by adding nodes
  • No single point of failure
  • Multi-data-centre replication
  • Fast, predictable reads for planned queries
  • Tunable consistency
⚠️ Cons
  • Query-first modelling is hard to get right
  • No joins, limited ad hoc queries
  • Data is duplicated across tables
  • Operations are complex (compaction, repair, tombstones)
  • Eventual consistency unless you pay for quorum
  • Wrong partition key causes hot spots

Trade-offs

ChoiceWe gainWe lose
Big partitionsFewer reads for a rangeHot spots, slow compaction, memory pressure
Small partitionsEven spreadRange queries touch many partitions
Consistency ONESpeed and availabilityReads may be stale
Consistency QUORUMStronger reads and writesMore latency, less tolerance for node loss
Table per queryFast reads for eachDuplicate data, more writes, you keep copies in sync
Higher RFDurability and availabilityMore disk and write traffic

10Common Problems and Mistakes

Common mistakes

  1. Modelling like SQL. A normalized design with joins does not exist here. Start from queries.
  2. A low-cardinality partition key. Keying by country or by status puts most data on a few partitions.
  3. Unbounded partitions. A key like user_id alone for a chatty user grows forever. Add a time bucket.
  4. ALLOW FILTERING in production. It scans everything and may time out.
  5. Many deletes or queue-like use. Tombstones pile up and reads slow down.
  6. Secondary indexes everywhere. They can hit many nodes. Prefer a table per query.
  7. Treating it as ACID. Multi-row transactions are limited. Lightweight transactions exist but are slow.

Things to watch

🔥Hot partitions
A single busy key (a celebrity, one sensor) overloads its replicas.
🪦Tombstones
Too many deleted markers slow reads and can cause errors.
🔁Repairs
Replicas drift apart. Run anti-entropy repair regularly.
🧹Compaction
Background merging uses disk and CPU. Plan capacity for it.

11Real-World Examples

📘Apache Cassandra
Started at Facebook (inbox search), now open source. Used by companies such as Netflix and Apple for huge, always-on data.
🟦Google Bigtable
Described in a 2006 paper. Behind many Google products and offered as Cloud Bigtable.
🐘HBase
An open-source Bigtable-style store on Hadoop's file system.
⚡ScyllaDB
A Cassandra-compatible database written in C++ for lower latency per node.
☁️Managed options
Amazon Keyspaces, Azure Managed Instance for Cassandra and DataStax Astra run it for you.
💬Messaging at scale
Chat and activity feeds are common fits (general idea; each company's design differs).
📝Note
These are general ideas. Names, features and limits change by version and vendor.
Mini case: chat history
💬Send message
→↓write
🧱Partition(chat_id, day)
→↓sorted by time
📱Open chatlatest 50, one read
Partition by conversation and day, cluster by time. Loading the latest messages reads one sorted slice.

12Related Topics to Read Next

Common Database Types→

Where wide-column stores sit among the others.

LSM Trees→

The write-optimised engine inside Cassandra and Bigtable.

Partitioning→

The general idea behind the partition key.

Replication→

How copies of each partition are kept.

CAP Theorem→

Why Cassandra lets you tune consistency against availability.

Time Series Databases→

A common use of wide rows, with extra time features.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • ✔What: partitioned, sorted tables over many nodes, built for heavy writes.
  • ✔Partition key: hashed to pick the node. Must appear in every query.
  • ✔Clustering key: sorts rows inside a partition. Enables range reads.
  • ✔Model: queries first, one table per query, duplicate data on purpose.
  • ✔Fast writes: commit log, memtable, SSTables, compaction (LSM).
  • ✔Consistency: tunable. QUORUM reads plus QUORUM writes overlap.
  • ✔Avoid: hot or unbounded partitions, ALLOW FILTERING, many deletes.
  • ✔One line: “Pick the machine with the partition key, keep rows sorted with the clustering key, and design for your queries.”
← Previous
Full-Text Search Engines
Next →
Time Series Databases