Book Image

Learning Apache Cassandra

By : Matthew Brown
4 (1)
Book Image

Learning Apache Cassandra

4 (1)
By: Matthew Brown

Overview of this book

Table of Contents (19 chapters)
Learning Apache Cassandra
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Storing follow relationships


We've now created two tables, each of which allows us to answer an important question about follow relationships: first, whom does a user follow; and second, who follows a user. Now let's establish some follow relationships.

For now, let's have alice follow a couple of other users, bob and carol:

INSERT INTO "user_outbound_follows"
  ("follower_username", "followed_username")
VALUES ('alice', 'bob');
INSERT INTO "user_inbound_follows"
  ("followed_username", "follower_username")
VALUES ('bob', 'alice');
INSERT INTO "user_outbound_follows"
  ("follower_username", "followed_username")
VALUES ('alice', 'carol');
INSERT INTO "user_inbound_follows"
  ("followed_username", "follower_username")
VALUES ('carol', 'alice');

For each follow relationship, we have to insert two rows: one in the user_outbound_follows table to store the relationship from the perspective of the follower, and one in the user_inbound_follows table to store the relationship from the perspective of...