SELECT wages FROM companies WHERE coders = “sucker”




                                  NO, NO SQL




Wednesday, 21 July 2010
Noise




Wednesday, 21 July 2010
Lots of pretty pictures to fool you.




Wednesday, 21 July 2010
Its a change




                          Its Not Relational - Get Over It.




                              It is a rich document store.




                                                             schemas for mongo : http://www.kurl.ws/wJ


Wednesday, 21 July 2010
What




                              MongoDB bridges the gap between key-value stores (which are
                              fast and highly scalable) and traditional RDBMS systems (which
                              provide rich queries and deep functionality).

                              MongoDB (from "humongous") is a scalable, high-performance,
                              open source, document-oriented database. Written in C++,
                              MongoDB features:



                          •   Document-oriented storage » JSON-style documents with dynamic schemas offer simplicity and power.
                          •   Full Index Support » Index on any attribute, just like you're used to.
                          •   Replication & High Availability »Mirror across LANs and WANs for scale and peace of mind.
                          •   Auto-Sharding » Scale horizontally without compromising functionality.
                          •   Querying » Rich, document-based queries.
                          •   Fast In-Place Updates »Atomic modifiers for contention-free performance.
                          •   Map/Reduce » Flexible aggregation and data processing.
                          •   GridFS » Store files of any size without complicating your stack.
                          •   Commercial Support »Commercial support, training, and consulting available.




                                                                                                             schemas for mongo : http://www.kurl.ws/wJ


Wednesday, 21 July 2010
Supported Drivers




                           mongodb.org Supported
                            •   C
                            •   C++
                            •   Java
                            •   Javascript
                            •   Perl
                            •   PHP
                            •   Python
                            •   Ruby
                           Community Supported
                                                   •   Lua
                            •   REST
                                                   •   node.js
                            •   C# and .NET
                                                   •   Objective C
                            •   Clojure
                                                   •   PHP
                            •   ColdFusion
                                                   •   PowerShell
                            •   Delphi
                                                   •   Python
                            •   Erlang
                                                   •   Ruby
                            •   Factor
                                                   •   Scala
                            •   Fantom
                                                   •   Scheme (PLT)
                            •   F#
                                                   •   Smalltalk
                            •   Go
                            •   Groovy
                            •   Haskell
                            •   Javascript




                                                                      more info: www.mongodb.org


Wednesday, 21 July 2010
Install on ubuntu




                                            EDIT YOUR SOURCES FILE
                                             nano /etc/apt/sources.list

                                            ADD THE FOLLOWING LINE
                             deb http://downloads.mongodb.org/distros/ubuntu 9.4 10gen

                                                NOW UPDATE APT
                                                   apt-get update
                                           apt-get install mongodb-stable

                                              apt-get install php5-dev

                                           INSTALL THE PHP DRIVER
                                               pecl install mongo




                                                                                    All Instructions http://kurl.ws/wH


Wednesday, 21 July 2010
Install on ubuntu   view db stats : http://localhost:28017/




Wednesday, 21 July 2010
Durability




                          Durability - You had to ask
                                Long long story




Wednesday, 21 July 2010
Examples - from the console




Wednesday, 21 July 2010
Examples - from the console




             > db.accounts.count() 1
             > db.accounts.find().forEach(function(doc){
                   print(tojson(doc));
             });




Wednesday, 21 July 2010
Examples - from the console


        > use testing
          switched to db testing
        > db.colors.insert({name:'red', primary:true})
        > db.colors.insert({name:'green', primary:true})
        > db.colors.insert({name:'blue', primary:true})
        > db.colors.insert({name:'purple', primary:false})
        > db.colors.insert({name:'orange', primary:false})
        > db.colors.insert({name:'yellow', primary:false})


        SELECT * from colors WHERE name = 'green' ; because I am sucker.

        > db.colors.find({name:'green'})
        { "_id" : ObjectId("4bed7af40b4acd070c593ba7"), "name" : "green",
        "primary" : true }




Wednesday, 21 July 2010
Examples - from the console




         Skip and Limit
        db.users.find().skip(20).limit(10);

         Limiting Fields, only get ssn
        db.users.find({last_name: 'Smith'}, {'ssn': 1});

         Greater than
        db.collection.find({ "field" : { $gt: value } } );

         Values in Embeded Objects
        db.postings.find( { "author.name" : "joe" } );

         Sort
        db.myCollection.find().sort( { ts : -1 } ); // sort by ts, descending order

         Upsert
        db.people.update( { name:"Joe" }, { $inc: { x:1, y:1 } }, true );




Wednesday, 21 July 2010
Examples - Real PHP




Wednesday, 21 July 2010
Examples - Real PHP




Wednesday, 21 July 2010
OLD




Wednesday, 21 July 2010
OLD




Wednesday, 21 July 2010
Mongo Hub GUI




Wednesday, 21 July 2010
backup




                          -fsync (mongo command)
                          - shutdown copy /data/db
                                - mongodump




Wednesday, 21 July 2010
or




                          Facebook still uses MySQL, a lot. Wikipedia uses MySQL, a
                          lot. FriendFeed uses MySQL, a lot. NoSQL is a great tool, but
                          it’s certainly not going to be your competitive edge, it’s not
                          going to make your app hot, and most of all, your users won’t
                          give a shit about any of this.
                          What am I going to build my next app on? Probably Postgres.
                          Will I use NoSQL? Maybe. I might also use Hadoop and Hive.
                          I might keep everything in flat files. Maybe I’ll start hacking on
                          Maglev. I’ll use whatever is best for the job. If I need reporting,
                          I won’t be using any NoSQL. If I need caching, I’ll probably use
                          Tokyo Tyrant. If I need ACIDity, I won’t use NoSQL. If I need
                          a ton of counters, I’ll use Redis. If I need transactions, I’ll use
                          Postgres. If I have a ton of a single type of documents, I’ll
                          probably use Mongo. If I need to write 1 billion objects a day,
                          I’d probably use Voldemort. If I need full text search, I’d
                          probably use Solr. If I need full text search of volatile data, I’d
                          probably use Sphinx.



Wednesday, 21 July 2010

Bar Camp Auckland - Mongo DB Presentation BCA4

  • 1.
    SELECT wages FROMcompanies WHERE coders = “sucker” NO, NO SQL Wednesday, 21 July 2010
  • 2.
  • 3.
    Lots of prettypictures to fool you. Wednesday, 21 July 2010
  • 4.
    Its a change Its Not Relational - Get Over It. It is a rich document store. schemas for mongo : http://www.kurl.ws/wJ Wednesday, 21 July 2010
  • 5.
    What MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide rich queries and deep functionality). MongoDB (from "humongous") is a scalable, high-performance, open source, document-oriented database. Written in C++, MongoDB features: • Document-oriented storage » JSON-style documents with dynamic schemas offer simplicity and power. • Full Index Support » Index on any attribute, just like you're used to. • Replication & High Availability »Mirror across LANs and WANs for scale and peace of mind. • Auto-Sharding » Scale horizontally without compromising functionality. • Querying » Rich, document-based queries. • Fast In-Place Updates »Atomic modifiers for contention-free performance. • Map/Reduce » Flexible aggregation and data processing. • GridFS » Store files of any size without complicating your stack. • Commercial Support »Commercial support, training, and consulting available. schemas for mongo : http://www.kurl.ws/wJ Wednesday, 21 July 2010
  • 6.
    Supported Drivers mongodb.org Supported • C • C++ • Java • Javascript • Perl • PHP • Python • Ruby Community Supported • Lua • REST • node.js • C# and .NET • Objective C • Clojure • PHP • ColdFusion • PowerShell • Delphi • Python • Erlang • Ruby • Factor • Scala • Fantom • Scheme (PLT) • F# • Smalltalk • Go • Groovy • Haskell • Javascript more info: www.mongodb.org Wednesday, 21 July 2010
  • 7.
    Install on ubuntu EDIT YOUR SOURCES FILE nano /etc/apt/sources.list ADD THE FOLLOWING LINE deb http://downloads.mongodb.org/distros/ubuntu 9.4 10gen NOW UPDATE APT apt-get update apt-get install mongodb-stable apt-get install php5-dev INSTALL THE PHP DRIVER pecl install mongo All Instructions http://kurl.ws/wH Wednesday, 21 July 2010
  • 8.
    Install on ubuntu view db stats : http://localhost:28017/ Wednesday, 21 July 2010
  • 9.
    Durability Durability - You had to ask Long long story Wednesday, 21 July 2010
  • 10.
    Examples - fromthe console Wednesday, 21 July 2010
  • 11.
    Examples - fromthe console > db.accounts.count() 1 > db.accounts.find().forEach(function(doc){ print(tojson(doc)); }); Wednesday, 21 July 2010
  • 12.
    Examples - fromthe console > use testing switched to db testing > db.colors.insert({name:'red', primary:true}) > db.colors.insert({name:'green', primary:true}) > db.colors.insert({name:'blue', primary:true}) > db.colors.insert({name:'purple', primary:false}) > db.colors.insert({name:'orange', primary:false}) > db.colors.insert({name:'yellow', primary:false}) SELECT * from colors WHERE name = 'green' ; because I am sucker. > db.colors.find({name:'green'}) { "_id" : ObjectId("4bed7af40b4acd070c593ba7"), "name" : "green", "primary" : true } Wednesday, 21 July 2010
  • 13.
    Examples - fromthe console Skip and Limit db.users.find().skip(20).limit(10); Limiting Fields, only get ssn db.users.find({last_name: 'Smith'}, {'ssn': 1}); Greater than db.collection.find({ "field" : { $gt: value } } ); Values in Embeded Objects db.postings.find( { "author.name" : "joe" } ); Sort db.myCollection.find().sort( { ts : -1 } ); // sort by ts, descending order Upsert db.people.update( { name:"Joe" }, { $inc: { x:1, y:1 } }, true ); Wednesday, 21 July 2010
  • 14.
    Examples - RealPHP Wednesday, 21 July 2010
  • 15.
    Examples - RealPHP Wednesday, 21 July 2010
  • 16.
  • 17.
  • 18.
  • 19.
    backup -fsync (mongo command) - shutdown copy /data/db - mongodump Wednesday, 21 July 2010
  • 20.
    or Facebook still uses MySQL, a lot. Wikipedia uses MySQL, a lot. FriendFeed uses MySQL, a lot. NoSQL is a great tool, but it’s certainly not going to be your competitive edge, it’s not going to make your app hot, and most of all, your users won’t give a shit about any of this. What am I going to build my next app on? Probably Postgres. Will I use NoSQL? Maybe. I might also use Hadoop and Hive. I might keep everything in flat files. Maybe I’ll start hacking on Maglev. I’ll use whatever is best for the job. If I need reporting, I won’t be using any NoSQL. If I need caching, I’ll probably use Tokyo Tyrant. If I need ACIDity, I won’t use NoSQL. If I need a ton of counters, I’ll use Redis. If I need transactions, I’ll use Postgres. If I have a ton of a single type of documents, I’ll probably use Mongo. If I need to write 1 billion objects a day, I’d probably use Voldemort. If I need full text search, I’d probably use Solr. If I need full text search of volatile data, I’d probably use Sphinx. Wednesday, 21 July 2010