Explain Cassandra's data model: Keyspaces, Tables (Column Families), Rows, Partition Keys, and Clustering Columns.
Last updated
Cassandra's data model is a hierarchy: a keyspace holds tables, tables hold rows keyed by a primary key, and that primary key splits into a partition key (which node owns the data) and clustering columns (how rows are sorted within the partition).
Keyspace: Top-level namespace, analogous to a database; defines the replication strategy and factor for all its tables.
Table (Column Family): A collection of rows with a defined schema; the older term is column family.
Row: A set of columns uniquely identified by its primary key.
Partition key: The first part of the primary key; hashed to a token to decide which node(s) store the data. All rows sharing it live together in one partition.
Clustering columns: Remaining primary-key columns that sort rows within a partition, enabling efficient range scans and ordering.
[lang:sql]
CREATE TABLE messages (
room_id text, -- partition key
sent_at timestamp, -- clustering column (sort order)
user text,
body text,
PRIMARY KEY ((room_id), sent_at)
) WITH CLUSTERING ORDER BY (sent_at DESC);
- https://www.wecreateproblems.com/interview-questions/cassandra-interview-questions
- https://mindmajix.com/cassandra-interview-questions-and-answers
- https://www.whizlabs.com/blog/cassandra-interview-questions-and-answers/
- https://www.analyticsvidhya.com/blog/2023/03/top-5-interview-questions-on-cassandra/
- https://www.geeksforgeeks.org/dbms/cassandra-vs-dynamodb/
- https://www.knowi.com/blog/cassandra-vs-dynamodb-2025-complete-guide-with-pricing-performance-usecase-migration-tips/
- https://www.bytebase.com/blog/dynamodb-vs-cassandra/
- https://dzone.com/articles/cassandra-vs-dynamodb-database-comparison
- https://www.finalroundai.com/blog/cassandra-interview-questions
- https://www.edureka.co/blog/interview-questions/cassandra-interview-questions/
- https://data-flair.training/blogs/cassandra-interview-questions/
- https://www.adaface.com/blog/cassandra-interview-questions/
- https://www.careers360.com/courses-certifications/articles/apache-cassandra-interview-questions
- https://www.acte.in/cassandra-interview-questions-and-answers
- https://www.devopsschool.com/blog/top-50-interview-questions-and-answers-of-apache-cassandra/