Cassandra Overview and Data Model
What you'll learn: How Cassandra organizes data into column families, partitions, and rows to achieve massive horizontal scalability.
What Is Cassandra?
Apache Cassandra is a distributed wide-column store designed for handling enormous amounts of data across many commodity servers with no single point of failure. Born at Facebook and open-sourced in 2008, it combines the distributed architecture of Amazon's Dynamo with the data model of Google's Bigtable.
The Column-Family Data Model
Cassandra organizes data into keyspaces (similar to databases), which contain column families (also called tables). Unlike relational tables, column families can hold sparse, variable-width rows.
A row in Cassandra is identified by a partition key (sometimes called the row key). Each row contains columns as name-value pairs. Think of it like a map within a map: the outer key locates the row, and inside you have flexible key-value columns.
Partitions: The Distribution Unit
The partition key determines which node(s) store the data. Cassandra uses consistent hashing (recall from earlier lessons) to distribute rows across the cluster. All rows with the same partition key live together, which is critical for query efficiency.
Clustering columns optionally sort data within a partition. For example, a time-series table might partition by user ID and cluster by timestamp, allowing fast retrieval of a user's recent events.
Structure Analogy
Imagine a filing cabinet (keyspace) with drawers (column families). Each drawer holds folders (partitions/rows) labeled by partition key. Inside each folder are index cards (columns) that can vary per folder—some folders might have 5 cards, others 500.
Key Takeaway: Cassandra's data model centers on partition keys that determine data distribution, with rows containing flexible columns organized in column families—optimized for write-heavy, horizontally scalable workloads.