KEMBAR78
An Introduction To NoSQL & MongoDB | PPTX
An Introduction ToNoSQL & MongoDBLee TheobaldTwitter: @LeesyEmail: Lee@LTheobald.co.uk
NoSQLA form of database management system that is non-relational.Systems are often schema less, avoid joins & are easy to scale.The term NoSQL was coined in 1998 by Carlo Strozzi and then again in early 2009 with the no:sql(east) conferenceA better term would have been “NoREL” but NoSQL caught on.  Think of it more as meaning “Not Only SQL”
But Why Choose NoSQL?Amount of data stored is on the up & up.Facebook is rumoured to hold over 50TB of data in their NoSQL system for their inbox searchThe data we store is more complex than 15 years ago.Easy DistributionWith all this data is needs to be easy to be able to add/remove servers without any disruption of service.
Choose Your FlavourKey-Value StoreGraphBigTableDocument Store
Key-Value StoreData is stored in (unsurpisingly) key/value pairs.Designed to handle lots of data and heavy loadBased on a Amazon’s Dynamo PaperExample: Voldermort (http://project-voldemort.com/) - Developed by the guys at LinkedIn
GraphFocuses on modeling data & associated connectionsInspired by mathematical Graph Theory.Example: FlockDB (http://github.com/twitter/flockdb) – developed by Twitter
BigTable / Column FamiliesBased on the BigTable paper from GoogleData is grouped by columns, not rows.Example: Cassandra (http://cassandra.apache.org/) – Originally developed by Facebook, now and Apache project.
Document StoreData stored as whole documents.JSON & XML are popular formatsMaps well to an Object Orientated programming modelExample: CouchDB (http://couchdb.apache.org/) or …{ “id”: “123”, “name”: “Oliver Clothesoff”, “dob”: {   “year”: 1985,   “month”: 5,   “day”: 12  }}
MongoDB!Short for humongousOpen source with development lead by 10GenDocument BasedSchema-lessHighly ScalableMapReduceEasy Replication & Sharding
Familiar StructureA MongoDB instance is made up of a number of databases.These contain a number of collections & you can have collections nested under other collections.Compare it to MySQL which has databases and tables.
Inserts – As Easy As Pieuse cookbook;db.recipes.save({ “name”: “Cherry Pie”, “ingredients”: [“cherries”, “pie”], “cooking_time”: 30});
Searching – A Piece Of Cake!db.recipes.find({ “cooking_time”: { “$gte”: 10, “$lt”: 30 }}db.recipes.findOne()
Some More Advanced SyntaxLimiting Resultsdb.find().limit(10);Skipping resultsdb.find().skip(5);Sortingdb.find().sort({cooking_time: -1});Cursors:var cur = db.find().cursor();cur.forEach( function(x) { print(tojson(x)); });
MapReduceGreat way of doing bulk manipulation or aggregation.2 or 3 functions written in JavaScript that execute on the server.An example use could be generating a list of top queries from some search logs.
Map FunctionTakes some input of the form of key/value pairs, performs some calculations and returns 0 or more key/value pairsmap = function() {    if (!this.query) {        return;    }    emit (this.query, {count: 1});}
Reduce FunctionTakes the results from the map function, does something (normally combine the results) and produces output in key/value pairsreduce = function(key, values) {var count = 0;values.forEach(function(v) {        count += v[‘count’];    }    return {count: count;}}
Replica SetsMaster/Slave configurationIf your primary server goes down, one of the secondary ones takes overautomaticallyExtremely easy to setup
Auto Sharding – Horizontal Scaling
Other FeaturesGridFS support – Distributed file storageGeospatial indexingIt’s constantly in development so new features are being worked on all the time!
Why Not Try It YourselfDownload it at: http://www.mongodb.orgOnline tutorial at:http://www.mongodb.org/display/DOCS/TutorialSome handy MongoDB sites:MongoDB Cookbook: http://cookbook.mongodb.org/Kyle Banker’s blog: http://kylebanker.com/blog/There’salso a load of handyreferencecards, stickers and otherMongoDBfreebiesupfront!
Thanks For ListeningAny questions?

An Introduction To NoSQL & MongoDB

  • 1.
    An Introduction ToNoSQL& MongoDBLee TheobaldTwitter: @LeesyEmail: Lee@LTheobald.co.uk
  • 2.
    NoSQLA form ofdatabase management system that is non-relational.Systems are often schema less, avoid joins & are easy to scale.The term NoSQL was coined in 1998 by Carlo Strozzi and then again in early 2009 with the no:sql(east) conferenceA better term would have been “NoREL” but NoSQL caught on. Think of it more as meaning “Not Only SQL”
  • 3.
    But Why ChooseNoSQL?Amount of data stored is on the up & up.Facebook is rumoured to hold over 50TB of data in their NoSQL system for their inbox searchThe data we store is more complex than 15 years ago.Easy DistributionWith all this data is needs to be easy to be able to add/remove servers without any disruption of service.
  • 4.
    Choose Your FlavourKey-ValueStoreGraphBigTableDocument Store
  • 5.
    Key-Value StoreData isstored in (unsurpisingly) key/value pairs.Designed to handle lots of data and heavy loadBased on a Amazon’s Dynamo PaperExample: Voldermort (http://project-voldemort.com/) - Developed by the guys at LinkedIn
  • 6.
    GraphFocuses on modelingdata & associated connectionsInspired by mathematical Graph Theory.Example: FlockDB (http://github.com/twitter/flockdb) – developed by Twitter
  • 7.
    BigTable / ColumnFamiliesBased on the BigTable paper from GoogleData is grouped by columns, not rows.Example: Cassandra (http://cassandra.apache.org/) – Originally developed by Facebook, now and Apache project.
  • 8.
    Document StoreData storedas whole documents.JSON & XML are popular formatsMaps well to an Object Orientated programming modelExample: CouchDB (http://couchdb.apache.org/) or …{ “id”: “123”, “name”: “Oliver Clothesoff”, “dob”: { “year”: 1985, “month”: 5, “day”: 12 }}
  • 9.
    MongoDB!Short for humongousOpensource with development lead by 10GenDocument BasedSchema-lessHighly ScalableMapReduceEasy Replication & Sharding
  • 10.
    Familiar StructureA MongoDBinstance is made up of a number of databases.These contain a number of collections & you can have collections nested under other collections.Compare it to MySQL which has databases and tables.
  • 11.
    Inserts – AsEasy As Pieuse cookbook;db.recipes.save({ “name”: “Cherry Pie”, “ingredients”: [“cherries”, “pie”], “cooking_time”: 30});
  • 12.
    Searching – APiece Of Cake!db.recipes.find({ “cooking_time”: { “$gte”: 10, “$lt”: 30 }}db.recipes.findOne()
  • 13.
    Some More AdvancedSyntaxLimiting Resultsdb.find().limit(10);Skipping resultsdb.find().skip(5);Sortingdb.find().sort({cooking_time: -1});Cursors:var cur = db.find().cursor();cur.forEach( function(x) { print(tojson(x)); });
  • 14.
    MapReduceGreat way ofdoing bulk manipulation or aggregation.2 or 3 functions written in JavaScript that execute on the server.An example use could be generating a list of top queries from some search logs.
  • 15.
    Map FunctionTakes someinput of the form of key/value pairs, performs some calculations and returns 0 or more key/value pairsmap = function() { if (!this.query) { return; } emit (this.query, {count: 1});}
  • 16.
    Reduce FunctionTakes theresults from the map function, does something (normally combine the results) and produces output in key/value pairsreduce = function(key, values) {var count = 0;values.forEach(function(v) { count += v[‘count’]; } return {count: count;}}
  • 17.
    Replica SetsMaster/Slave configurationIfyour primary server goes down, one of the secondary ones takes overautomaticallyExtremely easy to setup
  • 18.
    Auto Sharding –Horizontal Scaling
  • 19.
    Other FeaturesGridFS support– Distributed file storageGeospatial indexingIt’s constantly in development so new features are being worked on all the time!
  • 20.
    Why Not TryIt YourselfDownload it at: http://www.mongodb.orgOnline tutorial at:http://www.mongodb.org/display/DOCS/TutorialSome handy MongoDB sites:MongoDB Cookbook: http://cookbook.mongodb.org/Kyle Banker’s blog: http://kylebanker.com/blog/There’salso a load of handyreferencecards, stickers and otherMongoDBfreebiesupfront!
  • 21.