August 2016
Intermediate to advanced
196 pages
4h 21m
English
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.
We'll start with a basic query by key:
SELECT * FROM authors WHERE name = 'Tom Clancy'; ...
Read now
Unlock full access