In order to make sense of the various types of queries, we will start with a common data model to be used across the following examples. For this data model, we will return to the authors
table, with name
as the partition key, followed by year
and title
as clustering columns. We'll also sort the year in descending order. This table can be created as follows:
CREATE TABLE authors ( name text, year int, title text, isbn text, publisher text, PRIMARY KEY (name, year, title) ) WITH CLUSTERING ORDER BY (year DESC);
Also, for the purposes of these examples, we will assume a replication factor of 3 and consistency level of QUORUM.