SlideShare a Scribd company logo
DATASTAX C*OLLEGE CREDIT:

DATA MODELLING FOR
 APACHE CASSANDRA
                      Aaron Morton
Apache Cassandra Committer, Data Stax MVP for Apache Cassandra
                      @aaronmorton
                   www.thelastpickle.com


            Licensed under a Creative Commons Attribution-NonCommercial 3.0 New Zealand License
General Guidelines
   API Choice
    Example
Cassandra is good at

reading data from a row in the
      order it is stored.
Typically an efficient data model will

 denormalize data and use the
    storage engine order.
To create a good data model

 understand the queries your
    application requires.
General Guidelines
   API Choice
    Example
Multiple API’s?

  initially only a Thrift / RPC
 API, used by language specific
              clients.
Multiple API’s...

   Cassandra Query Language
   (CQL) started as a higher
  level, declarative alternative.
Multiple API’s...

  CQL 3 brings many changes.
    Currently in Beta in
       Cassandra v1.1
CQL 3 uses

  a Table Orientated, Schema
      Driven, Data Model.
       (I said it had many changes.)
General Guidelines
   API Choice
    Example
Twitter Clone
  Previously done with Thrift at WDCNZ

   “Hello @World #Cassandra - Apache
           Cassandra in action”
        http://vimeo.com/49762233
Twitter clone...

   using CQL 3 via the cqlsh
            tool.
       bin/cqlsh -3
Queries?
        * Post Tweet to Followers
             * Get Tweet by ID
           * List Tweets by User
      * List Tweets in User Timeline
              * List Followers
Keyspace is

     a namespace container.
Our Keyspace
CREATE KEYSPACE
     cass_college
WITH
     strategy_class = 'NetworkTopologyStrategy'
AND
    strategy_options:datacenter1 = 1;
Table is

   a sparse collection of well
   known, ordered columns.
First Table
CREATE TABLE User
(
    user_name text,
    password text,
    real_name text,
    PRIMARY KEY (user_name)
);
Some users...
cqlsh:cass_college> INSERT INTO User
                ...     (user_name, password, real_name)
                ... VALUES
                ...     ('fred', 'sekr8t', 'Mr Foo');

cqlsh:cass_college> select * from User;
 user_name | password | real_name
-----------+----------+-----------
      fred |   sekr8t |    Mr Foo
Some users...
cqlsh:cass_college> INSERT INTO User
                ...     (user_name, password)
                ... VALUES
                ...     ('bob', 'pwd');


cqlsh:cass_college> select * from User where user_name =
'bob';
 user_name | password | real_name
-----------+----------+-----------
       bob |      pwd |      null
Data Model (so far)

                      User
Data Model (so far)
      CF /
                   User
      Value



    user_name   Primary Key
Tweet Table
CREATE TABLE Tweet
(
    tweet_id    bigint,
    body        text,
    user_name   text,
    timestamp   timestamp,
    PRIMARY KEY (tweet_id)
);
Tweet Table...
cqlsh:cass_college> INSERT INTO Tweet
                ...     (tweet_id, body, user_name, timestamp)
                ... VALUES
                ...     (1, 'The Tweet','fred',1352150816917);

cqlsh:cass_college> select * from Tweet where tweet_id = 1;
 tweet_id | body      | timestamp                | user_name
----------+-----------+--------------------------+-----------
        1 | The Tweet | 2012-11-06 10:26:56+1300 |      fred
Data Model (so far)
      CF /
                   User         Tweet
      Value



    user_name   Primary Key      Field




    tweet_id                  Primary Key
UserTweets Table
CREATE TABLE UserTweets
(
    tweet_id    bigint,
    user_name   text,
    body        text,
    timestamp   timestamp,
    PRIMARY KEY (user_name, tweet_id)
);
UserTweets Table...
cqlsh:cass_college> INSERT INTO UserTweets
                ...     (tweet_id, body, user_name, timestamp)
                ... VALUES
                ...     (1, 'The Tweet','fred',1352150816917);

cqlsh:cass_college> select * from UserTweets where
user_name='fred';

 user_name | tweet_id | body      | timestamp
-----------+----------+-----------+--------------------------
      fred |        1 | The Tweet | 2012-11-06 10:26:56+1300
UserTweets Table...
cqlsh:cass_college> select * from UserTweets where
user_name='fred' and tweet_id=1;

 user_name | tweet_id | body      | timestamp
-----------+----------+-----------+--------------------------
      fred |        1 | The Tweet | 2012-11-06 10:26:56+1300
UserTweets Table...
cqlsh:cass_college> INSERT INTO UserTweets
                ...     (tweet_id, body, user_name, timestamp)
                ... VALUES
                ...     (2, 'Second Tweet', 'fred', 1352150816918);

cqlsh:cass_college> select * from UserTweets where user_name = 'fred';
 user_name | tweet_id | body         | timestamp
-----------+----------+--------------+--------------------------
      fred |        1 |    The Tweet | 2012-11-06 10:26:56+1300
      fred |        2 | Second Tweet | 2012-11-06 10:26:56+1300
UserTweets Table...
cqlsh:cass_college> select * from UserTweets where user_name = 'fred' order by
tweet_id desc;

 user_name | tweet_id | body         | timestamp
-----------+----------+--------------+--------------------------
      fred |        2 | Second Tweet | 2012-11-06 10:26:56+1300
      fred |        1 |    The Tweet | 2012-11-06 10:26:56+1300
UserTimeline
CREATE TABLE UserTimeline
(
    tweet_id    bigint,
    user_name   text,
    body        text,
    timestamp   timestamp,
    PRIMARY KEY (user_name, tweet_id)
);
Data Model (so far)
   CF /                                     User          User
                User         Tweet
   Value                                   Tweets       Timeline



 user_name   Primary Key      Field      Primary Key   Primary Key



                                         Primary Key   Primary Key
  tweet_id                 Primary Key
                                         Component     Component
UserMetrics Table
CREATE TABLE UserMetrics
(
    user_name   text,
    tweets      counter,
    followers   counter,
    following   counter,
    PRIMARY KEY (user_name)
);
UserMetrics Table...
cqlsh:cass_college> UPDATE
                ...      UserMetrics
                ... SET
                ...      tweets = tweets + 1
                ... WHERE
                ...      user_name = 'fred';
cqlsh:cass_college> select * from UserMetrics where user_name
= 'fred';
 user_name | followers | following | tweets
-----------+-----------+-----------+--------
      fred |      null |       null |      1
Data Model (so far)
   CF /                             User         User
              User     Tweet                               User Metrics
   Value                           Tweets      Timeline


             Primary              Primary      Primary       Primary
 user_name              Field
               Key                  Key          Key           Key


                       Primary   Primary Key Primary Key
 tweet_id
                         Key     Component Component
Relationships
CREATE TABLE Followers
(
    user_name       text,
    follower        text,
    timestamp       timestamp,
    PRIMARY KEY (user_name, follower)
);

CREATE TABLE Following
(
    user_name       text,
    following       text,
    timestamp       timestamp,
    PRIMARY KEY (user_name, following)
);
Relationships
INSERT INTO
    Following
    (user_name, following, timestamp)
VALUES
    ('bob', 'fred', 1352247749161);
INSERT INTO
    Followers
    (user_name, follower, timestamp)
VALUES
    ('fred', 'bob', 1352247749161);
Relationships
cqlsh:cass_college> select * from Following;
 user_name | following | timestamp
-----------+-----------+--------------------------
       bob |      fred | 2012-11-07 13:22:29+1300

cqlsh:cass_college> select * from Followers;
 user_name | follower | timestamp
-----------+----------+--------------------------
      fred |      bob | 2012-11-07 13:22:29+1300
Data Model
  CF /                             User        User        User      Follows
             User     Tweet
  Value                           Tweets     Timeline     Metrics   Followers


                                                                    Primary
            Primary              Primary     Primary      Primary
user_name              Field                                          Key
              Key                  Key         Key          Key
                                                                     Field


                      Primary   Primary Key Primary Key
 tweet_id
                        Key     Component Component
Thanks.
Aaron Morton
                     @aaronmorton
                   www.thelastpickle.com




Licensed under a Creative Commons Attribution-NonCommercial 3.0 New Zealand License

More Related Content

PDF
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
PPTX
Introduction to Apache Cassandra
PPTX
Apache Cassandra, part 2 – data model example, machinery
PPTX
Apache Cassandra, part 3 – machinery, work with Cassandra
PDF
Cassandra summit 2013 - DataStax Java Driver Unleashed!
PDF
Introduction to Cassandra & Data model
PDF
Tokyo cassandra conference 2014
PDF
Cassandra Summit 2013 Keynote
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Introduction to Apache Cassandra
Apache Cassandra, part 2 – data model example, machinery
Apache Cassandra, part 3 – machinery, work with Cassandra
Cassandra summit 2013 - DataStax Java Driver Unleashed!
Introduction to Cassandra & Data model
Tokyo cassandra conference 2014
Cassandra Summit 2013 Keynote

What's hot (20)

PPT
Scaling web applications with cassandra presentation
PPTX
C*ollege Credit: Creating Your First App in Java with Cassandra
PPTX
Psycopg2 - Connect to PostgreSQL using Python Script
PDF
Programming with Python and PostgreSQL
PDF
"PostgreSQL and Python" Lightning Talk @EuroPython2014
PDF
Replication MongoDB Days 2013
PPTX
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
PDF
Linux system admin
PPTX
Introduction to PostgreSQL
PDF
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)
PDF
MongoDB Database Replication
PDF
Postgres can do THAT?
PDF
glance replicator
PPTX
Replication and Replica Sets
PPTX
Webinar: Replication and Replica Sets
PDF
2013 london advanced-replication
PPTX
Replication and Replica Sets
TXT
Oracle ORA Errors
PDF
Redis SoCraTes 2014
PPTX
Replication and replica sets
Scaling web applications with cassandra presentation
C*ollege Credit: Creating Your First App in Java with Cassandra
Psycopg2 - Connect to PostgreSQL using Python Script
Programming with Python and PostgreSQL
"PostgreSQL and Python" Lightning Talk @EuroPython2014
Replication MongoDB Days 2013
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
Linux system admin
Introduction to PostgreSQL
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)
MongoDB Database Replication
Postgres can do THAT?
glance replicator
Replication and Replica Sets
Webinar: Replication and Replica Sets
2013 london advanced-replication
Replication and Replica Sets
Oracle ORA Errors
Redis SoCraTes 2014
Replication and replica sets
Ad

Viewers also liked (16)

PPTX
Webinar - Security and Manageability: Key Criteria in Selecting Enterprise-Gr...
PPTX
Introducing DataStax Enterprise 4.7
PDF
What is DataStax Enterprise?
KEY
C*ollege Credit: An Introduction to Apache Cassandra
PPT
Community Webinar: 15 Commandments of Cassandra DBAs
PDF
Cassandra Community Webinar | The World's Next Top Data Model
PDF
Cassandra Community Webinar | Data Model on Fire
PDF
Understanding Data Consistency in Apache Cassandra
PPTX
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
PDF
Data Modeling a Scheduling App (Adam Hutson, DataScale) | Cassandra Summit 2016
PDF
How Do I Cassandra?
PPTX
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
PDF
Understanding Data Partitioning and Replication in Apache Cassandra
PDF
What is in All of Those SSTable Files Not Just the Data One but All the Rest ...
PPTX
An Overview of Apache Cassandra
PPTX
Webinar - DataStax Enterprise 5.1: 3X the operational analytics speed, help f...
Webinar - Security and Manageability: Key Criteria in Selecting Enterprise-Gr...
Introducing DataStax Enterprise 4.7
What is DataStax Enterprise?
C*ollege Credit: An Introduction to Apache Cassandra
Community Webinar: 15 Commandments of Cassandra DBAs
Cassandra Community Webinar | The World's Next Top Data Model
Cassandra Community Webinar | Data Model on Fire
Understanding Data Consistency in Apache Cassandra
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
Data Modeling a Scheduling App (Adam Hutson, DataScale) | Cassandra Summit 2016
How Do I Cassandra?
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
Understanding Data Partitioning and Replication in Apache Cassandra
What is in All of Those SSTable Files Not Just the Data One but All the Rest ...
An Overview of Apache Cassandra
Webinar - DataStax Enterprise 5.1: 3X the operational analytics speed, help f...
Ad

Similar to C*ollege Credit: Data Modeling for Apache Cassandra (20)

PDF
Cassandra By Example: Data Modelling with CQL3
PDF
Cassandra by Example: Data Modelling with CQL3
PDF
Apache Cassandra Lesson: Data Modelling and CQL3
PDF
NoSQL Overview
PDF
CQL3 in depth
PPTX
Apache Cassandra Developer Training Slide Deck
PDF
CQL3 and Data Modeling 101 with Apache Cassandra
PDF
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
PPTX
Understanding How CQL3 Maps to Cassandra's Internal Data Structure
KEY
Building a Highly Scalable, Open Source Twitter Clone
PDF
Cassandra 2012
PDF
Slide presentation pycassa_upload
PPTX
Just in time (series) - KairosDB
KEY
Cassandra presentation - Geek Nights Braga
PDF
Cassandra Summit 2014: Understanding CQL3 Inside and Out
PDF
CQL In Cassandra 1.0 (and beyond)
PPTX
Cassandra
PDF
Introduction to Data Modeling with Apache Cassandra
PDF
Introduction to data modeling with apache cassandra
PDF
Cassandra Day Atlanta 2015: Data Modeling 101
Cassandra By Example: Data Modelling with CQL3
Cassandra by Example: Data Modelling with CQL3
Apache Cassandra Lesson: Data Modelling and CQL3
NoSQL Overview
CQL3 in depth
Apache Cassandra Developer Training Slide Deck
CQL3 and Data Modeling 101 with Apache Cassandra
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
Understanding How CQL3 Maps to Cassandra's Internal Data Structure
Building a Highly Scalable, Open Source Twitter Clone
Cassandra 2012
Slide presentation pycassa_upload
Just in time (series) - KairosDB
Cassandra presentation - Geek Nights Braga
Cassandra Summit 2014: Understanding CQL3 Inside and Out
CQL In Cassandra 1.0 (and beyond)
Cassandra
Introduction to Data Modeling with Apache Cassandra
Introduction to data modeling with apache cassandra
Cassandra Day Atlanta 2015: Data Modeling 101

More from DataStax (20)

PPTX
Is Your Enterprise Ready to Shine This Holiday Season?
PPTX
Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...
PPTX
Running DataStax Enterprise in VMware Cloud and Hybrid Environments
PPTX
Best Practices for Getting to Production with DataStax Enterprise Graph
PPTX
Webinar | Data Management for Hybrid and Multi-Cloud: A Four-Step Journey
PPTX
Webinar | How to Understand Apache Cassandra™ Performance Through Read/Writ...
PDF
Webinar | Better Together: Apache Cassandra and Apache Kafka
PDF
Top 10 Best Practices for Apache Cassandra and DataStax Enterprise
PDF
Introduction to Apache Cassandra™ + What’s New in 4.0
PPTX
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
PPTX
Webinar | Aligning GDPR Requirements with Today's Hybrid Cloud Realities
PDF
Designing a Distributed Cloud Database for Dummies
PDF
How to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
PDF
How to Evaluate Cloud Databases for eCommerce
PPTX
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
PPTX
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
PPTX
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
PPTX
Datastax - The Architect's guide to customer experience (CX)
PPTX
An Operational Data Layer is Critical for Transformative Banking Applications
PPTX
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking
Is Your Enterprise Ready to Shine This Holiday Season?
Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...
Running DataStax Enterprise in VMware Cloud and Hybrid Environments
Best Practices for Getting to Production with DataStax Enterprise Graph
Webinar | Data Management for Hybrid and Multi-Cloud: A Four-Step Journey
Webinar | How to Understand Apache Cassandra™ Performance Through Read/Writ...
Webinar | Better Together: Apache Cassandra and Apache Kafka
Top 10 Best Practices for Apache Cassandra and DataStax Enterprise
Introduction to Apache Cassandra™ + What’s New in 4.0
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
Webinar | Aligning GDPR Requirements with Today's Hybrid Cloud Realities
Designing a Distributed Cloud Database for Dummies
How to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
How to Evaluate Cloud Databases for eCommerce
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
Datastax - The Architect's guide to customer experience (CX)
An Operational Data Layer is Critical for Transformative Banking Applications
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking

C*ollege Credit: Data Modeling for Apache Cassandra

  • 1. DATASTAX C*OLLEGE CREDIT: DATA MODELLING FOR APACHE CASSANDRA Aaron Morton Apache Cassandra Committer, Data Stax MVP for Apache Cassandra @aaronmorton www.thelastpickle.com Licensed under a Creative Commons Attribution-NonCommercial 3.0 New Zealand License
  • 2. General Guidelines API Choice Example
  • 3. Cassandra is good at reading data from a row in the order it is stored.
  • 4. Typically an efficient data model will denormalize data and use the storage engine order.
  • 5. To create a good data model understand the queries your application requires.
  • 6. General Guidelines API Choice Example
  • 7. Multiple API’s? initially only a Thrift / RPC API, used by language specific clients.
  • 8. Multiple API’s... Cassandra Query Language (CQL) started as a higher level, declarative alternative.
  • 9. Multiple API’s... CQL 3 brings many changes. Currently in Beta in Cassandra v1.1
  • 10. CQL 3 uses a Table Orientated, Schema Driven, Data Model. (I said it had many changes.)
  • 11. General Guidelines API Choice Example
  • 12. Twitter Clone Previously done with Thrift at WDCNZ “Hello @World #Cassandra - Apache Cassandra in action” http://vimeo.com/49762233
  • 13. Twitter clone... using CQL 3 via the cqlsh tool. bin/cqlsh -3
  • 14. Queries? * Post Tweet to Followers * Get Tweet by ID * List Tweets by User * List Tweets in User Timeline * List Followers
  • 15. Keyspace is a namespace container.
  • 16. Our Keyspace CREATE KEYSPACE cass_college WITH strategy_class = 'NetworkTopologyStrategy' AND strategy_options:datacenter1 = 1;
  • 17. Table is a sparse collection of well known, ordered columns.
  • 18. First Table CREATE TABLE User ( user_name text, password text, real_name text, PRIMARY KEY (user_name) );
  • 19. Some users... cqlsh:cass_college> INSERT INTO User ... (user_name, password, real_name) ... VALUES ... ('fred', 'sekr8t', 'Mr Foo'); cqlsh:cass_college> select * from User; user_name | password | real_name -----------+----------+----------- fred | sekr8t | Mr Foo
  • 20. Some users... cqlsh:cass_college> INSERT INTO User ... (user_name, password) ... VALUES ... ('bob', 'pwd'); cqlsh:cass_college> select * from User where user_name = 'bob'; user_name | password | real_name -----------+----------+----------- bob | pwd | null
  • 21. Data Model (so far) User
  • 22. Data Model (so far) CF / User Value user_name Primary Key
  • 23. Tweet Table CREATE TABLE Tweet ( tweet_id bigint, body text, user_name text, timestamp timestamp, PRIMARY KEY (tweet_id) );
  • 24. Tweet Table... cqlsh:cass_college> INSERT INTO Tweet ... (tweet_id, body, user_name, timestamp) ... VALUES ... (1, 'The Tweet','fred',1352150816917); cqlsh:cass_college> select * from Tweet where tweet_id = 1; tweet_id | body | timestamp | user_name ----------+-----------+--------------------------+----------- 1 | The Tweet | 2012-11-06 10:26:56+1300 | fred
  • 25. Data Model (so far) CF / User Tweet Value user_name Primary Key Field tweet_id Primary Key
  • 26. UserTweets Table CREATE TABLE UserTweets ( tweet_id bigint, user_name text, body text, timestamp timestamp, PRIMARY KEY (user_name, tweet_id) );
  • 27. UserTweets Table... cqlsh:cass_college> INSERT INTO UserTweets ... (tweet_id, body, user_name, timestamp) ... VALUES ... (1, 'The Tweet','fred',1352150816917); cqlsh:cass_college> select * from UserTweets where user_name='fred'; user_name | tweet_id | body | timestamp -----------+----------+-----------+-------------------------- fred | 1 | The Tweet | 2012-11-06 10:26:56+1300
  • 28. UserTweets Table... cqlsh:cass_college> select * from UserTweets where user_name='fred' and tweet_id=1; user_name | tweet_id | body | timestamp -----------+----------+-----------+-------------------------- fred | 1 | The Tweet | 2012-11-06 10:26:56+1300
  • 29. UserTweets Table... cqlsh:cass_college> INSERT INTO UserTweets ... (tweet_id, body, user_name, timestamp) ... VALUES ... (2, 'Second Tweet', 'fred', 1352150816918); cqlsh:cass_college> select * from UserTweets where user_name = 'fred'; user_name | tweet_id | body | timestamp -----------+----------+--------------+-------------------------- fred | 1 | The Tweet | 2012-11-06 10:26:56+1300 fred | 2 | Second Tweet | 2012-11-06 10:26:56+1300
  • 30. UserTweets Table... cqlsh:cass_college> select * from UserTweets where user_name = 'fred' order by tweet_id desc; user_name | tweet_id | body | timestamp -----------+----------+--------------+-------------------------- fred | 2 | Second Tweet | 2012-11-06 10:26:56+1300 fred | 1 | The Tweet | 2012-11-06 10:26:56+1300
  • 31. UserTimeline CREATE TABLE UserTimeline ( tweet_id bigint, user_name text, body text, timestamp timestamp, PRIMARY KEY (user_name, tweet_id) );
  • 32. Data Model (so far) CF / User User User Tweet Value Tweets Timeline user_name Primary Key Field Primary Key Primary Key Primary Key Primary Key tweet_id Primary Key Component Component
  • 33. UserMetrics Table CREATE TABLE UserMetrics ( user_name text, tweets counter, followers counter, following counter, PRIMARY KEY (user_name) );
  • 34. UserMetrics Table... cqlsh:cass_college> UPDATE ... UserMetrics ... SET ... tweets = tweets + 1 ... WHERE ... user_name = 'fred'; cqlsh:cass_college> select * from UserMetrics where user_name = 'fred'; user_name | followers | following | tweets -----------+-----------+-----------+-------- fred | null | null | 1
  • 35. Data Model (so far) CF / User User User Tweet User Metrics Value Tweets Timeline Primary Primary Primary Primary user_name Field Key Key Key Key Primary Primary Key Primary Key tweet_id Key Component Component
  • 36. Relationships CREATE TABLE Followers ( user_name text, follower text, timestamp timestamp, PRIMARY KEY (user_name, follower) ); CREATE TABLE Following ( user_name text, following text, timestamp timestamp, PRIMARY KEY (user_name, following) );
  • 37. Relationships INSERT INTO Following (user_name, following, timestamp) VALUES ('bob', 'fred', 1352247749161); INSERT INTO Followers (user_name, follower, timestamp) VALUES ('fred', 'bob', 1352247749161);
  • 38. Relationships cqlsh:cass_college> select * from Following; user_name | following | timestamp -----------+-----------+-------------------------- bob | fred | 2012-11-07 13:22:29+1300 cqlsh:cass_college> select * from Followers; user_name | follower | timestamp -----------+----------+-------------------------- fred | bob | 2012-11-07 13:22:29+1300
  • 39. Data Model CF / User User User Follows User Tweet Value Tweets Timeline Metrics Followers Primary Primary Primary Primary Primary user_name Field Key Key Key Key Key Field Primary Primary Key Primary Key tweet_id Key Component Component
  • 41. Aaron Morton @aaronmorton www.thelastpickle.com Licensed under a Creative Commons Attribution-NonCommercial 3.0 New Zealand License