Database Reference
In-Depth Information
Inbound follows
Our new
user_outbound_follows
table allows us to efficiently find out who a user
follows; since the partition key is the username of the following user, we'll only be access-
ing a single partition to answer the question. It does not, however, provide any way to find
out who follows a certain user. In order to broadcast users' status updates to their followers,
we'll certainly need to be able to find out who their followers are.
To accomplish this, we'll create a new table, which is the mirror image of
user_outbound_follows
:
CREATE TABLE "user_inbound_follows" (
"followed_username" text,
"follower_username" text,
PRIMARY KEY ("followed_username", "follower_username")
);
The new
user_inbound_follows
table looks exactly like the
user_outbound_follows
table, except that the order of the keys is reversed: now the
followed user's username is the partition key, and each row within the partition is identified
by the follower user's username. Like
user_outbound_follows
, our new table does
not have any non-key columns.