October 2018
Beginner to intermediate
348 pages
10h
English
Cassandra comes with the ability to apply distributed, secondary indexes on arbitrary columns in a table. For an application of this, let's look at a different solution for our order_status table. For starters, we'll add the date/time of the order as a clustering column. Next, we'll store the total as a BIGINT representing the number of cents (instead of DECIMAL for dollars), to ensure that we maintain our precision accuracy. But the biggest difference is that, in talking with our business resources, we will discover that bucketing by week will give us a partition of manageable size:
CREATE TABLE order_status_by_week ( week_bucket bigint, order_datetime timestamp, order_id uuid, shipping_weight_kg decimal, status text,