Cassandra - Primary Key

Card Puncher Data Processing

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
Card Puncher Data Processing
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....



Share this page:
Follow us:
Task Runner