Cassandra - Primary Key

Data Modeling Chebotko Logical

Cassandra - Primary Key

About

This page talks about the primary key of a cassandra table.

The primary key is composed of:

If you’re searching by an attribute, this attribute should be a part of the primary key

Example

Example of a primary with:

  • the partition key columns channel_id, bucket
  • the clustering column message_id. The message id is unique.
CREATE TABLE messages (
   channel_id bigint,
   bucket int,
   message_id bigint,
   author_id bigint,
   content text,
   PRIMARY KEY ((channel_id, bucket), message_id)
) WITH CLUSTERING ORDER BY (message_id DESC);





Discover More
Data Modeling Chebotko Logical
Cassandra - Clustering Column

The clustering columns are columns from the primary key that: guarantee uniqueness and support the sort ordering Attributes that are used in a range query are good candidate for clustering columns....
Data Modeling Chebotko Logical
Cassandra - Partition

A partition in Cassandra is a unit of storage that does not get divided across nodes. A partition is an ordered dictionary (ordered by clustering key). A partition is a file and should be kept small...
Data Modeling Chebotko Logical
Cassandra NoSql Database

Cassandra is a NoSql database for transactional workloads that require high scale and maximum availability. Cassandra is suited for transactional workloads at high volume and shouldn’t be considered...



Share this page:
Follow us:
Task Runner