The form of the single table

To demonstrate this approach, we'll start by creating a new table, user_follows, that has an identical structure to our user_inbound_follows table:

CREATE TABLE "user_follows" (   "followed_username" text,   "follower_username" text,   PRIMARY KEY ("followed_username", "follower_username") );

As with user_outbound_follows, this new table uses a followed user as its partition key and the follower as its clustering column. At a higher level, for each user, U, this table stores a partition of rows representing the users that follow U. So, if we'd like to find out who follows a given user, we can do so very efficiently using this table.

However, we've said that we want to use the same table for both inbound and outbound ...

Get Learning Apache Cassandra - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.