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 ...