O'Reilly logo

Learning Apache Cassandra - Second Edition by Sandeep Yarabarla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Multiple clustering columns

Clustering columns are not limited to one field as specified before. Let's take a look at how multiple clustering columns work and facilitate data ordering. To illustrate this, we will recreate our status updates table so that it is clustered by the date and time when the user updated their status:

CREATE TABLE "user_status_updates_by_datetime" (   "username" text,   "status_date" date,   "status_time" time,   "body" text,   PRIMARY KEY ("username", "status_date", "status_time") );

We have created a new table user_status_updates_by_datetime as shown next:

  • Partition key: username, which is a text field.
  • Clustering columns: status_date and status_time. Rows for a particular username are clustered by both columns, first ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required