One Size fits All




                             David Funaro
domenica 3 aprile 2011
-
                         One Size fits-All




                             David Funaro
domenica 3 aprile 2011
Why i’m Here

                         “There must be a better way to
                         design this model”
                         ?????????????????????????????????


domenica 3 aprile 2011
Evolution of the persistence

                                          TIME
                           ’60

                         Application




                SINGLE USER

               Everything in inside the
               application, every time
               we have to spend time
               to reinvent the wheel


domenica 3 aprile 2011
Evolution of the persistence

                                                  TIME
                           ’60                  ’70/80

                                                Application
                         Application
                                                  Library



                SINGLE USER                SINGLE USER

               Everything in inside the
                                          a good way to develop. All
               application, every time
                                          the business logic is in the
               we have to spend time
                                          Library
               to reinvent the wheel


domenica 3 aprile 2011
Evolution of the persistence

                                                  TIME
                           ’60                  ’70/80                          ’90

                                                Application
                         Application
                                                  Library
                                                                              RDBMS


                SINGLE USER                SINGLE USER                      MULTI-USER

               Everything in inside the
                                          a good way to develop. All
               application, every time
                                          the business logic is in the   Centralized storage of the
               we have to spend time
                                          Library                        model
               to reinvent the wheel


domenica 3 aprile 2011
Data-Driven
                         Application Design


                                   Data




                               Application
domenica 3 aprile 2011
Way to Develop

          • Define ER:
           • Indentify every Entities
           • Foeach entity find all the
                         attributes




domenica 3 aprile 2011
Active Record


                “Active record is an approach to accessing data in a
                 database. A database table or view is wrapped into
                                      a class.”
                                                             Wikipedia




domenica 3 aprile 2011
...but NOT always



domenica 3 aprile 2011
...but NOT always
                           is the right way


domenica 3 aprile 2011
1:Real Case: plugin
                    UserEvent                  Event
                   User_id    100              id : 12
                   event_id   12




domenica 3 aprile 2011
1:Real Case: plugin
                    UserEvent                  Event
                   User_id    100              id : 12
                   event_id   12

                                           Document
                                            id : 54




domenica 3 aprile 2011
1:Real Case: plugin
                    UserEvent                  Event
                   User_id    100              id : 12
                   event_id   12

                                           Document
                                            id : 54


                                               Group
                                               id : 78


domenica 3 aprile 2011
1:Real Case: plugin
                    UserEvent                  Event
                   User_id    100              id : 12
                   event_id   12

                                              Document
                           UserEntity          id : 54
                     User_id          100
                       Class       Document
                     entity_id         12      Group
                                               id : 78


domenica 3 aprile 2011
1:Real Case: plugin
                    UserEvent                  Event
                   User_id    100              id : 12
                   event_id   12

                                              Document
                           UserEntity          id : 54
                     User_id          100
                       Class       Document
                     entity_id         12      Group
                                               id : 78


domenica 3 aprile 2011
1:Real Case: plugin
                    UserEvent                  Event
                   User_id    100              id : 12
                   event_id   12

                                              Document
                           UserEntity          id : 54
                     User_id          100
                       Class       Document
                     entity_id         12      Group
                                               id : 78


domenica 3 aprile 2011
1:Real Case: plugin
                    UserEvent                  Event
                   User_id    100              id : 12
                   event_id   12

                                              Document
                           UserEntity          id : 54
                     User_id          100
                       Class       Document
                     entity_id         12      Group
                                               id : 78


domenica 3 aprile 2011
1:Real Case: plugin
                    UserEvent                             Event
                   User_id    100                         id : 12
                   event_id   12

                                                         Document
                           UserEntity                     id : 54
                     User_id          100
                       Class       Document
                     entity_id         12                 Group
                                                          id : 78
                                    Integrity : Broken
domenica 3 aprile 2011
1:Real Case: Redundance
                 UserEvent
                                  Event
                User_id    100
                                  id : 12
                event_id   12

           UserDocument
            User_id   100        Document
          document_id 12          id : 54

             UserGroup
                                  Group
            User_id   100
                                  id : 78
          document_id 12


domenica 3 aprile 2011
1:Real Case: menu
      Home:
      •page
      •event
      •group
      •document




domenica 3 aprile 2011
1:Real Case: menu
                                      Menu
                              name           home
      Home:                menu_item_id        2
      •page
      •event
      •group
      •document




domenica 3 aprile 2011
1:Real Case: menu
                                       Menu
                              name               home
      Home:                menu_item_id            2
      •page
      •event                          MenuItem
      •group                   name              home
      •document             menu_item_id            2
                                class            Group
                              entity_id            id




domenica 3 aprile 2011
1:Real Case: menu
                                       Menu
                              name               home
      Home:                menu_item_id            2
      •page
      •event                          MenuItem
      •group                   name              home
      •document             menu_item_id            2
                                class            Group
                              entity_id            id



         Event
         id : 12


domenica 3 aprile 2011
1:Real Case: menu
                                       Menu
                              name               home
      Home:                menu_item_id            2
      •page
      •event                          MenuItem
      •group                   name              home
      •document             menu_item_id            2
                                class            Group
                              entity_id            id



         Event                                           Document
         id : 12                                          id : 54


domenica 3 aprile 2011
1:Real Case: menu
                                       Menu
                              name               home
      Home:                menu_item_id            2
      •page
      •event                          MenuItem
      •group                   name              home
      •document             menu_item_id            2
                                class            Group
                              entity_id            id



         Event                        Group              Document
         id : 12                      id : 78             id : 54


domenica 3 aprile 2011
1:Real Case: menu
                                       Menu
                              name               home
      Home:                menu_item_id            2
      •page
      •event                          MenuItem
      •group                   name              home
      •document             menu_item_id            2
                                class            Group
                              entity_id            id



         Event                        Group              Document
         id : 12                      id : 78             id : 54


domenica 3 aprile 2011
1:Real Case: menu
                                       Menu
                              name               home
      Home:                menu_item_id            2
      •page
      •event                          MenuItem
      •group                   name              home
      •document             menu_item_id            2
                                class            Group
                              entity_id            id



         Event                        Group              Document
         id : 12                      id : 78             id : 54


domenica 3 aprile 2011
1:Real Case: menu
                                       Menu
                              name               home
      Home:                menu_item_id            2
      •page
      •event                          MenuItem
      •group                   name              home
      •document             menu_item_id            2
                                class            Group
                              entity_id            id



         Event                        Group              Document
         id : 12                      id : 78             id : 54


domenica 3 aprile 2011
Impedence
           mismatch

domenica 3 aprile 2011
Design Model




domenica 3 aprile 2011
Design Model           Application Needs




domenica 3 aprile 2011
Design Model           |
                         =   Application Needs




domenica 3 aprile 2011
Design Model                           |
                                         =           Application Needs

                 Comportamenti che i modelli non sono in grado di supportare




domenica 3 aprile 2011
Arrangement


  Design Model                           |
                                         =           Application Needs

                 Comportamenti che i modelli non sono in grado di supportare




domenica 3 aprile 2011
Technology focus




domenica 3 aprile 2011
Technology focus




domenica 3 aprile 2011
Bad RDBMS Cases



domenica 3 aprile 2011
Data Mapping
                 Struttura Dati           RDBMS

                                          id    10


                                      name     pippo


                                   parent_id    19




domenica 3 aprile 2011
The Alien


                            Different Behaviour
                            Different Model




domenica 3 aprile 2011
Unpredictable
                            Tomorrow

                    • User Story never complete
                    • User Story evolve


domenica 3 aprile 2011
Bad DBMS Cases
                • Dynamic Pages
                • Data mapping
                • The Alien
                • Producer/Consumer
                • Overnormalized
                • Unpredictable tomorrow
domenica 3 aprile 2011
Bad DBMS Cases
                • Dynamic Pages
                • Data mapping
                • The Alien
                • Producer/Consumer
                • Overnormalized
                                           =
                • Unpredictable tomorrow
domenica 3 aprile 2011
Bad DBMS Cases
                • Dynamic Pages
                • Data mapping
                • The Alien
                • Producer/Consumer
                • Overnormalized
                                           =
                • Unpredictable tomorrow
domenica 3 aprile 2011
NoSql




domenica 3 aprile 2011
NoSql

                           Not Only
                             Sql


domenica 3 aprile 2011
NoSql

                             Not Only
                               Sql
                         Just find the right way
                         to manage our data-set
domenica 3 aprile 2011
NoSql



domenica 3 aprile 2011
document-                   document-
          TYPE             oriented
                                        key-value
                                                       oriented
                                                                      graph


                          Reliability /             Performance /
       FOCUS             doc-oriented
                                        Performance
                                                    doc-oriented
                                                                  edge relations

                                                                   Schema-less
     SCHEMA              Schema-less   Schema-less   Schema-less   Schema-full
                                                                      Mixed

domenica 3 aprile 2011
Performance


                    • Redis : about 110000 SETs per second,
                         about 81000 GETs per second.




domenica 3 aprile 2011
TYPE
                             Key - Value


                         ‘nome’ -> ‘Davidino’


domenica 3 aprile 2011
TYPE              document-Oriented


         ‘person’ -> ‘{
         ‘name’ : ‘david’,
         ‘surname’ : ‘funaro’,
         phones: [
              34702323,
              233234124,
              134014
            ]
         }’
                                                     JSon
domenica 3 aprile 2011
TYPE
                         Graph DB




                                    JSon
domenica 3 aprile 2011
More ...


domenica 3 aprile 2011
So ?




domenica 3 aprile 2011
So ?
                    • Removing impedence mismatch is a
                         good reason to avoid the relational
                         model




domenica 3 aprile 2011
So ?
                    • Removing impedence mismatch is a
                         good reason to avoid the relational
                         model
                    • Performances aren’t the only reason to
                         choose NoSQL




domenica 3 aprile 2011
So ?
                    • Removing impedence mismatch is a
                         good reason to avoid the relational
                         model
                    • Performances aren’t the only reason to
                         choose NoSQL
                    • A RDBMS isn’t always the proper
                         choice

domenica 3 aprile 2011
Thanks

                    • David Funaro
                    • http://www.davidfunaro.com
                    • @ingdavidino
                    • ing.davidino@gmail.com

domenica 3 aprile 2011

One size fit All

  • 1.
    One Size fitsAll David Funaro domenica 3 aprile 2011
  • 2.
    - One Size fits-All David Funaro domenica 3 aprile 2011
  • 3.
    Why i’m Here “There must be a better way to design this model” ????????????????????????????????? domenica 3 aprile 2011
  • 4.
    Evolution of thepersistence TIME ’60 Application SINGLE USER Everything in inside the application, every time we have to spend time to reinvent the wheel domenica 3 aprile 2011
  • 5.
    Evolution of thepersistence TIME ’60 ’70/80 Application Application Library SINGLE USER SINGLE USER Everything in inside the a good way to develop. All application, every time the business logic is in the we have to spend time Library to reinvent the wheel domenica 3 aprile 2011
  • 6.
    Evolution of thepersistence TIME ’60 ’70/80 ’90 Application Application Library RDBMS SINGLE USER SINGLE USER MULTI-USER Everything in inside the a good way to develop. All application, every time the business logic is in the Centralized storage of the we have to spend time Library model to reinvent the wheel domenica 3 aprile 2011
  • 7.
    Data-Driven Application Design Data Application domenica 3 aprile 2011
  • 8.
    Way to Develop • Define ER: • Indentify every Entities • Foeach entity find all the attributes domenica 3 aprile 2011
  • 9.
    Active Record “Active record is an approach to accessing data in a database. A database table or view is wrapped into a class.” Wikipedia domenica 3 aprile 2011
  • 10.
  • 11.
    ...but NOT always is the right way domenica 3 aprile 2011
  • 12.
    1:Real Case: plugin UserEvent Event User_id 100 id : 12 event_id 12 domenica 3 aprile 2011
  • 13.
    1:Real Case: plugin UserEvent Event User_id 100 id : 12 event_id 12 Document id : 54 domenica 3 aprile 2011
  • 14.
    1:Real Case: plugin UserEvent Event User_id 100 id : 12 event_id 12 Document id : 54 Group id : 78 domenica 3 aprile 2011
  • 15.
    1:Real Case: plugin UserEvent Event User_id 100 id : 12 event_id 12 Document UserEntity id : 54 User_id 100 Class Document entity_id 12 Group id : 78 domenica 3 aprile 2011
  • 16.
    1:Real Case: plugin UserEvent Event User_id 100 id : 12 event_id 12 Document UserEntity id : 54 User_id 100 Class Document entity_id 12 Group id : 78 domenica 3 aprile 2011
  • 17.
    1:Real Case: plugin UserEvent Event User_id 100 id : 12 event_id 12 Document UserEntity id : 54 User_id 100 Class Document entity_id 12 Group id : 78 domenica 3 aprile 2011
  • 18.
    1:Real Case: plugin UserEvent Event User_id 100 id : 12 event_id 12 Document UserEntity id : 54 User_id 100 Class Document entity_id 12 Group id : 78 domenica 3 aprile 2011
  • 19.
    1:Real Case: plugin UserEvent Event User_id 100 id : 12 event_id 12 Document UserEntity id : 54 User_id 100 Class Document entity_id 12 Group id : 78 Integrity : Broken domenica 3 aprile 2011
  • 20.
    1:Real Case: Redundance UserEvent Event User_id 100 id : 12 event_id 12 UserDocument User_id 100 Document document_id 12 id : 54 UserGroup Group User_id 100 id : 78 document_id 12 domenica 3 aprile 2011
  • 21.
    1:Real Case: menu Home: •page •event •group •document domenica 3 aprile 2011
  • 22.
    1:Real Case: menu Menu name home Home: menu_item_id 2 •page •event •group •document domenica 3 aprile 2011
  • 23.
    1:Real Case: menu Menu name home Home: menu_item_id 2 •page •event MenuItem •group name home •document menu_item_id 2 class Group entity_id id domenica 3 aprile 2011
  • 24.
    1:Real Case: menu Menu name home Home: menu_item_id 2 •page •event MenuItem •group name home •document menu_item_id 2 class Group entity_id id Event id : 12 domenica 3 aprile 2011
  • 25.
    1:Real Case: menu Menu name home Home: menu_item_id 2 •page •event MenuItem •group name home •document menu_item_id 2 class Group entity_id id Event Document id : 12 id : 54 domenica 3 aprile 2011
  • 26.
    1:Real Case: menu Menu name home Home: menu_item_id 2 •page •event MenuItem •group name home •document menu_item_id 2 class Group entity_id id Event Group Document id : 12 id : 78 id : 54 domenica 3 aprile 2011
  • 27.
    1:Real Case: menu Menu name home Home: menu_item_id 2 •page •event MenuItem •group name home •document menu_item_id 2 class Group entity_id id Event Group Document id : 12 id : 78 id : 54 domenica 3 aprile 2011
  • 28.
    1:Real Case: menu Menu name home Home: menu_item_id 2 •page •event MenuItem •group name home •document menu_item_id 2 class Group entity_id id Event Group Document id : 12 id : 78 id : 54 domenica 3 aprile 2011
  • 29.
    1:Real Case: menu Menu name home Home: menu_item_id 2 •page •event MenuItem •group name home •document menu_item_id 2 class Group entity_id id Event Group Document id : 12 id : 78 id : 54 domenica 3 aprile 2011
  • 30.
    Impedence mismatch domenica 3 aprile 2011
  • 31.
  • 32.
    Design Model Application Needs domenica 3 aprile 2011
  • 33.
    Design Model | = Application Needs domenica 3 aprile 2011
  • 34.
    Design Model | = Application Needs Comportamenti che i modelli non sono in grado di supportare domenica 3 aprile 2011
  • 35.
    Arrangement DesignModel | = Application Needs Comportamenti che i modelli non sono in grado di supportare domenica 3 aprile 2011
  • 36.
  • 37.
  • 38.
  • 39.
    Data Mapping Struttura Dati RDBMS id 10 name pippo parent_id 19 domenica 3 aprile 2011
  • 40.
    The Alien Different Behaviour Different Model domenica 3 aprile 2011
  • 41.
    Unpredictable Tomorrow • User Story never complete • User Story evolve domenica 3 aprile 2011
  • 42.
    Bad DBMS Cases • Dynamic Pages • Data mapping • The Alien • Producer/Consumer • Overnormalized • Unpredictable tomorrow domenica 3 aprile 2011
  • 43.
    Bad DBMS Cases • Dynamic Pages • Data mapping • The Alien • Producer/Consumer • Overnormalized = • Unpredictable tomorrow domenica 3 aprile 2011
  • 44.
    Bad DBMS Cases • Dynamic Pages • Data mapping • The Alien • Producer/Consumer • Overnormalized = • Unpredictable tomorrow domenica 3 aprile 2011
  • 45.
  • 46.
    NoSql Not Only Sql domenica 3 aprile 2011
  • 47.
    NoSql Not Only Sql Just find the right way to manage our data-set domenica 3 aprile 2011
  • 48.
  • 49.
    document- document- TYPE oriented key-value oriented graph Reliability / Performance / FOCUS doc-oriented Performance doc-oriented edge relations Schema-less SCHEMA Schema-less Schema-less Schema-less Schema-full Mixed domenica 3 aprile 2011
  • 50.
    Performance • Redis : about 110000 SETs per second, about 81000 GETs per second. domenica 3 aprile 2011
  • 51.
    TYPE Key - Value ‘nome’ -> ‘Davidino’ domenica 3 aprile 2011
  • 52.
    TYPE document-Oriented ‘person’ -> ‘{ ‘name’ : ‘david’, ‘surname’ : ‘funaro’, phones: [ 34702323, 233234124, 134014 ] }’ JSon domenica 3 aprile 2011
  • 53.
    TYPE Graph DB JSon domenica 3 aprile 2011
  • 54.
  • 55.
    So ? domenica 3aprile 2011
  • 56.
    So ? • Removing impedence mismatch is a good reason to avoid the relational model domenica 3 aprile 2011
  • 57.
    So ? • Removing impedence mismatch is a good reason to avoid the relational model • Performances aren’t the only reason to choose NoSQL domenica 3 aprile 2011
  • 58.
    So ? • Removing impedence mismatch is a good reason to avoid the relational model • Performances aren’t the only reason to choose NoSQL • A RDBMS isn’t always the proper choice domenica 3 aprile 2011
  • 59.
    Thanks • David Funaro • http://www.davidfunaro.com • @ingdavidino • ing.davidino@gmail.com domenica 3 aprile 2011