April 2017
Beginner to intermediate
360 pages
9h 35m
English
We'll start with the question Who do I follow?. We'll want a partition per user, with each partition containing all the other users they follow:
CREATE TABLE "user_outbound_follows" ( "follower_username" text, "followed_username" text, PRIMARY KEY ("follower_username", "followed_username") );
Simple enough, but there's something unusual here: there are only two columns in the table, and they're both part of the primary key. As it turns out, this is a perfectly valid way to construct a table schema; non-key columns are optional in Cassandra tables. Since all we need to know is who's at the other end of the follow relationship, which is available via the clustering column followed_user_id, no additional data columns are ...
Read now
Unlock full access