Skip to main content
To SQL
                             OR


                 No (T) SQL?
PFCongres 2012 Jeroen van Dijk
JEROEN VAN DIJK



∂ Nerd chief @ ENRISE
∂ PHPBenelux board member
∂ Zend Certified Engineer
∂ Web technology freak
∂ Open source addict

   JEROEN@ENRISE.COM   @NEOREY
THE ENRISE RESTAURANT




∂ We want to prepare the best dishes
∂ With the best ingredients
∂ To create a magical client experience!


∂ You engineers are our top chefs!
WHAT IS


ACID?
EVER HEARD OF

CAP
 THEOREM?
KNOW


ABC?
∂ Courtesy of Tim Anglade
Always

∂ Courtesy of Tim Anglade
Always
            Be
∂ Courtesy of Tim Anglade
Always
            Be
            Caching
∂ Courtesy of Tim Anglade
Always
            Be
            Caching
∂ Courtesy of Tim Anglade
JOIN THE HYPE?




WANT!==HAVE

                 13
HAVE TO USE NOSQL?




     SCALABILITY
                     &
  PERFORMANCE
                         14
HAVE TO USE NOSQL?




     SCALABILITY
                     &
  PERFORMANCE
                         15
RECAP RDBMS GREATNESS


∂   Standard Query Language
∂   ACID: Atomicity, Consistency, Isolation, Durability
∂   Supported by everyone and everything
∂   Tuning options
∂   Battle tested!
∂   Open source?!


    NOT ENOUGH?



                                                          16
MAKING LOADS OF MONEY?




                         17
BUY A BIGGER BOX




                   18
NOT SO GREAT RDBMS FEATURES


∂ Vertical scalability




                              19
NOT SO GREAT RDBMS FEATURES


∂ Vertical scalability



∂ Horizontal scalability




                              20
NOT SO GREAT RDBMS FEATURES


∂ Vertical scalability



∂ Horizontal scalability



∂ Schema changes!




                              21
SINCE 2004




DATA++++++
             22
WHO NEEDS


ACID!?
CAP THEOREM

                  AVAILABILITY
                       A




              C                  P
  CONSISTENCY                    PARTITION TOLERANCE
CAP THEOREM

                   AVAILABILITY
                        A
              CA                  AP


                      PICK
                      TWO
              C                   P
  CONSISTENCY                     PARTITION TOLERANCE
                        CP
CAP THEOREM

                                      AVAILABILITY
MySQL (InnoDB, not MyISAM)                             A                    Dynamo      Voldemort


PostgreSQL       SQL Server                                                 Cassandra      CouchDB

                              CA                                       AP
Oracle RAC       Neo4J                                                      SimpleDB    Riak



                                                PICK
                                                TWO
                              C                                         P
        CONSISTENCY                                                     PARTITION TOLERANCE
                                                       CP

                                          Hypertable        Hbase


                               BigTable          MongoDB       Terrastore


                              Couchbase          MemcacheDB         Redis
4   NOSQL
    TYPES
4 NOSQL TYPES


                KEY-VALUE




                COLUMN




                GRAPH




                DOCUMENT
4 NOSQL TYPES


                KEY-VALUE




                COLUMN




                GRAPH




                DOCUMENT
4 NOSQL TYPES


                KEY-VALUE




                COLUMN




                GRAPH




                DOCUMENT
4 NOSQL TYPES


                KEY-VALUE




                COLUMN




                GRAPH




                DOCUMENT
4 NOSQL TYPES


   KEY-VALUE




   COLUMN




   GRAPH




   DOCUMENT




∂ 122 known NoSQL databases
4 NOSQL TYPES


   KEY-VALUE




   COLUMN




   GRAPH




   DOCUMENT




∂ Focus from Redis, Riak, Neo4J, MongoDB
KEY - VALUE


   KEY-VALUE   ∂   Schema-less design
               ∂   Just strings of data
               ∂   Hard to query
   COLUMN
               ∂   Mostly in memory

   GRAPH




   DOCUMENT
KEY - VALUE


   KEY-VALUE
               [
   COLUMN          “key1” => “value1”,
                   “key2” => “value2”,
   GRAPH

                   “key3” => “value3”,
   DOCUMENT
               ]
REDIS


KEY-VALUE
            ∂    Blazing fast key-value implementation
            ∂    Master - slave replication
            ∂    Lots of methods to query data
COLUMN
            ∂    Notable options
                 ∂ Data types : Strings, hashes, lists, sets
GRAPH            ∂ Data expiration
                 ∂ Pub/Sub for messaging
DOCUMENT




         ∂ Reconsider when using Memcached
COLUMN


  KEY-VALUE   ∂   BigTable or Dynamo style
              ∂   Consistent hashing
              ∂   Vector clocks
  COLUMN
              ∂   Hinted hand off

  GRAPH




  DOCUMENT
COLUMN


   KEY-VALUE




   COLUMN




   GRAPH




   DOCUMENT




∂ Data stored in a ring
COLUMN

                                     D

KEY-VALUE




COLUMN


                       C                     A


GRAPH




DOCUMENT

                                     B



         ∂ Consistent hashing with 4 nodes
COLUMN


KEY-VALUE




COLUMN




GRAPH




DOCUMENT




         ∂ Partitioning as done by Riak
COLUMN


KEY-VALUE




COLUMN




GRAPH




DOCUMENT




         ∂ Read / Write....
COLUMN


KEY-VALUE




COLUMN




GRAPH




DOCUMENT




         ∂ Anywhere in the ring
COLUMN


KEY-VALUE




COLUMN




GRAPH




DOCUMENT




         ∂ First node joins the cluster, claims all partitions
COLUMN


KEY-VALUE    N=3                            A

                                                  B


                                                      C
COLUMN




GRAPH




DOCUMENT




         ∂ Reading / writing is done to 3 nodes
COLUMN


KEY-VALUE    N=3                            A

                                                B

             W=2                                    C
COLUMN
             R=2
GRAPH




DOCUMENT




         ∂ Reading / writing succeeds with 2 valid responses
COLUMN


KEY-VALUE    N=3                           A
                                                     [ Ov1,v2 ]
                                                 B

             W=2                                     C       [ Ov1 ]
COLUMN
             R=2
                                                         D
                                                              [ Ov1,v2 ]
GRAPH




DOCUMENT




         ∂ Node C down, while new write action
COLUMN


KEY-VALUE    N=3                              A
                                                      [ Ov1,v2 ]
                                                  B

             W=2                                      C       [ Ov1,v2 ]
COLUMN
             R=2
                                                          D
                                                               [ Ov1,v2 ]
GRAPH




DOCUMENT




         ∂ Node D hands the new version off
RIAK


   KEY-VALUE   ∂   Dynamo implementation
               ∂   MapReduce query style
               ∂   Multiple storage backends
   COLUMN
               ∂   Notable options
                   § Link walking (like Graph solutions)
   GRAPH
                   § Solr-like search interface
                   § Secondary indexes
   DOCUMENT
GRAPH


  KEY-VALUE   ∂ Relations more important then entities
              ∂ From RDBMS perspective : SELF JOINS

  COLUMN




  GRAPH




  DOCUMENT
GRAPH


   KEY-VALUE




   COLUMN




   GRAPH




   DOCUMENT




∂ Facebook style
GRAPH


KEY-VALUE




COLUMN




GRAPH




DOCUMENT




         ∂ Betweenness centrality
GRAPH


KEY-VALUE




COLUMN




GRAPH




DOCUMENT




         ∂ Degree centrality
GRAPH


KEY-VALUE




COLUMN




GRAPH




DOCUMENT




         ∂ Closeness centrality
GRAPH


KEY-VALUE




COLUMN




GRAPH




DOCUMENT




         ∂ Twitter style
GRAPH


KEY-VALUE



                              2
COLUMN                    1

                                  9       3           2
                              1       2       1
GRAPH                                             2
                              3
                                  3

DOCUMENT




         ∂ TomTom style
GRAPH


KEY-VALUE



                              2
COLUMN                    1

                                  9       3           2
                              1       2       1
GRAPH                                             2
                              3
                                  3

DOCUMENT




         ∂ TomTom style
GRAPH


KEY-VALUE



                              2
COLUMN                    1

                                  9       3           2
                              1       2       1
GRAPH                                             2
                              3
                                  3

DOCUMENT




         ∂ TomTom style
NEO4J


KEY-VALUE   ∂   ACID compliant
            ∂   Enterprise product for HA ($$$)
            ∂   Custom query language
COLUMN
            ∂   Notable options
                 § Self contained web admin
GRAPH




DOCUMENT
DOCUMENT


  KEY-VALUE   ∂ Largest resemblance with RDBMS
              ∂ MapReduce
              ∂ Software architect more important
  COLUMN




  GRAPH




  DOCUMENT
MONGODB


  KEY-VALUE   ∂   MySQL of it’s generation?!
              ∂   Master - slave structure
              ∂   MapReduce
  COLUMN
              ∂   Notable options
                  § Geo indexes
  GRAPH




  DOCUMENT
              SMALLEST LEARNING CURVE!
USE CASES

               ∂ Rapid changing data which fits in memory
   KEY-VALUE
               ∂ Analytics, logging, real-time data collection

   COLUMN




   GRAPH




   DOCUMENT
USE CASES

               ∂ Rapid changing data which fits in memory
   KEY-VALUE
               ∂ Analytics, logging, real-time data collection
               ∂ Very good availability & fault tolerance
   COLUMN
               ∂ Applications where seconds of downtime hurt

   GRAPH




   DOCUMENT
USE CASES

               ∂ Rapid changing data which fits in memory
   KEY-VALUE
               ∂ Analytics, logging, real-time data collection
               ∂ Very good availability & fault tolerance
   COLUMN
               ∂ Applications where seconds of downtime hurt
               ∂ For rich interconnected data
   GRAPH
               ∂ Social relational data, geo & maps data

   DOCUMENT
USE CASES

               ∂ Rapid changing data which fits in memory
   KEY-VALUE
               ∂ Analytics, logging, real-time data collection
               ∂ Very good availability & fault tolerance
   COLUMN
               ∂ Applications where seconds of downtime hurt
               ∂ For rich interconnected data
   GRAPH
               ∂ Social relational data, geo & maps data
               ∂ MySQL like usage with indexes
   DOCUMENT
               ∂ Any type of data you’d fit in MySQL
ONE USEFUL INGREDIENT




                        65
MORE GREAT TASTES




                    66
∂ KLIK VOOR FOOTER

                     67
Polyglot persistence?


∂ KLIK VOOR FOOTER

                                  68
∂ THANK YOU! FEEDBACK? JOIND.IN/7084
∂ MORE DETAILS? SCAN THIS CODE.