SlideShare a Scribd company logo
1 of 41
Download to read offline
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

What's hot

Scaling web applications with cassandra presentation
Scaling web applications with cassandra presentationScaling web applications with cassandra presentation
Scaling web applications with cassandra presentationMurat Çakal
 
C*ollege Credit: Creating Your First App in Java with Cassandra
C*ollege Credit: Creating Your First App in Java with CassandraC*ollege Credit: Creating Your First App in Java with Cassandra
C*ollege Credit: Creating Your First App in Java with CassandraDataStax
 
Psycopg2 - Connect to PostgreSQL using Python Script
Psycopg2 - Connect to PostgreSQL using Python ScriptPsycopg2 - Connect to PostgreSQL using Python Script
Psycopg2 - Connect to PostgreSQL using Python ScriptSurvey Department
 
Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQLPeter Eisentraut
 
"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014Henning Jacobs
 
Replication MongoDB Days 2013
Replication MongoDB Days 2013Replication MongoDB Days 2013
Replication MongoDB Days 2013Randall Hunt
 
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...MongoDB
 
Introduction to PostgreSQL
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQLJoel Brewer
 
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)Non-Relational Postgres / Bruce Momjian (EnterpriseDB)
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)Ontico
 
MongoDB Database Replication
MongoDB Database ReplicationMongoDB Database Replication
MongoDB Database ReplicationMehdi Valikhani
 
Postgres can do THAT?
Postgres can do THAT?Postgres can do THAT?
Postgres can do THAT?alexbrasetvik
 
glance replicator
glance replicatorglance replicator
glance replicatoririx_jp
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica SetsMongoDB
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica SetsMongoDB
 
2013 london advanced-replication
2013 london advanced-replication2013 london advanced-replication
2013 london advanced-replicationMarc Schwering
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica SetsMongoDB
 
Redis SoCraTes 2014
Redis SoCraTes 2014Redis SoCraTes 2014
Redis SoCraTes 2014steffenbauer
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica setsRandall Hunt
 

What's hot (20)

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

Viewers also liked

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

Viewers also liked (16)

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

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

Cassandra by Example: Data Modelling with CQL3
Cassandra by Example:  Data Modelling with CQL3Cassandra by Example:  Data Modelling with CQL3
Cassandra by Example: Data Modelling with CQL3Eric Evans
 
Introduction to data modeling with apache cassandra
Introduction to data modeling with apache cassandraIntroduction to data modeling with apache cassandra
Introduction to data modeling with apache cassandraPatrick McFadin
 
Development of Twitter Application #4 - Timeline and Tweet
Development of Twitter Application #4 - Timeline and TweetDevelopment of Twitter Application #4 - Timeline and Tweet
Development of Twitter Application #4 - Timeline and TweetMyungjin Lee
 
Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3Eric Evans
 
Cassandra Day Atlanta 2015: Data Modeling 101
Cassandra Day Atlanta 2015: Data Modeling 101Cassandra Day Atlanta 2015: Data Modeling 101
Cassandra Day Atlanta 2015: Data Modeling 101DataStax Academy
 
Cassandra Day Chicago 2015: Apache Cassandra Data Modeling 101
Cassandra Day Chicago 2015: Apache Cassandra Data Modeling 101Cassandra Day Chicago 2015: Apache Cassandra Data Modeling 101
Cassandra Day Chicago 2015: Apache Cassandra Data Modeling 101DataStax Academy
 
Cassandra Day London 2015: Data Modeling 101
Cassandra Day London 2015: Data Modeling 101Cassandra Day London 2015: Data Modeling 101
Cassandra Day London 2015: Data Modeling 101DataStax Academy
 
Development of Twitter Application #5 - Users
Development of Twitter Application #5 - UsersDevelopment of Twitter Application #5 - Users
Development of Twitter Application #5 - UsersMyungjin Lee
 
Advanced Data Modeling with Apache Cassandra
Advanced Data Modeling with Apache CassandraAdvanced Data Modeling with Apache Cassandra
Advanced Data Modeling with Apache CassandraDataStax Academy
 
"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)Portland R User Group
 
Apache Cassandra Lesson: Data Modelling and CQL3
Apache Cassandra Lesson: Data Modelling and CQL3Apache Cassandra Lesson: Data Modelling and CQL3
Apache Cassandra Lesson: Data Modelling and CQL3Markus Klems
 
Getting Started with OpenSplice and Esper
Getting Started with OpenSplice and EsperGetting Started with OpenSplice and Esper
Getting Started with OpenSplice and EsperAngelo Corsaro
 
Advanced data modeling with apache cassandra
Advanced data modeling with apache cassandraAdvanced data modeling with apache cassandra
Advanced data modeling with apache cassandraPatrick McFadin
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to CassandraHanborq Inc.
 
IBM Insight 2015 - 1824 - Using Bluemix and dashDB for Twitter Analysis
IBM Insight 2015 - 1824 - Using Bluemix and dashDB for Twitter AnalysisIBM Insight 2015 - 1824 - Using Bluemix and dashDB for Twitter Analysis
IBM Insight 2015 - 1824 - Using Bluemix and dashDB for Twitter AnalysisTorsten Steinbach
 
Introduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache CassandraIntroduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache CassandraLuke Tillman
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101Thomas Lee
 

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

Cassandra by Example: Data Modelling with CQL3
Cassandra by Example:  Data Modelling with CQL3Cassandra by Example:  Data Modelling with CQL3
Cassandra by Example: Data Modelling with CQL3
 
Introduction to data modeling with apache cassandra
Introduction to data modeling with apache cassandraIntroduction to data modeling with apache cassandra
Introduction to data modeling with apache cassandra
 
Development of Twitter Application #4 - Timeline and Tweet
Development of Twitter Application #4 - Timeline and TweetDevelopment of Twitter Application #4 - Timeline and Tweet
Development of Twitter Application #4 - Timeline and Tweet
 
Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3
 
Cassandra Day Atlanta 2015: Data Modeling 101
Cassandra Day Atlanta 2015: Data Modeling 101Cassandra Day Atlanta 2015: Data Modeling 101
Cassandra Day Atlanta 2015: Data Modeling 101
 
Cassandra Day Chicago 2015: Apache Cassandra Data Modeling 101
Cassandra Day Chicago 2015: Apache Cassandra Data Modeling 101Cassandra Day Chicago 2015: Apache Cassandra Data Modeling 101
Cassandra Day Chicago 2015: Apache Cassandra Data Modeling 101
 
Cassandra Day London 2015: Data Modeling 101
Cassandra Day London 2015: Data Modeling 101Cassandra Day London 2015: Data Modeling 101
Cassandra Day London 2015: Data Modeling 101
 
Development of Twitter Application #5 - Users
Development of Twitter Application #5 - UsersDevelopment of Twitter Application #5 - Users
Development of Twitter Application #5 - Users
 
Advanced Data Modeling with Apache Cassandra
Advanced Data Modeling with Apache CassandraAdvanced Data Modeling with Apache Cassandra
Advanced Data Modeling with Apache Cassandra
 
"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)
 
Cassandra
CassandraCassandra
Cassandra
 
Apache Cassandra Lesson: Data Modelling and CQL3
Apache Cassandra Lesson: Data Modelling and CQL3Apache Cassandra Lesson: Data Modelling and CQL3
Apache Cassandra Lesson: Data Modelling and CQL3
 
Getting Started with OpenSplice and Esper
Getting Started with OpenSplice and EsperGetting Started with OpenSplice and Esper
Getting Started with OpenSplice and Esper
 
Advanced data modeling with apache cassandra
Advanced data modeling with apache cassandraAdvanced data modeling with apache cassandra
Advanced data modeling with apache cassandra
 
Stored procedures
Stored proceduresStored procedures
Stored procedures
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
 
IBM Insight 2015 - 1824 - Using Bluemix and dashDB for Twitter Analysis
IBM Insight 2015 - 1824 - Using Bluemix and dashDB for Twitter AnalysisIBM Insight 2015 - 1824 - Using Bluemix and dashDB for Twitter Analysis
IBM Insight 2015 - 1824 - Using Bluemix and dashDB for Twitter Analysis
 
Twixer (english)
Twixer (english)Twixer (english)
Twixer (english)
 
Introduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache CassandraIntroduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache Cassandra
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101
 

More from DataStax

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

More from DataStax (20)

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