SlideShare a Scribd company logo
1 of 73
Download to read offline
Stash the Hash!

MongoDB is the MashupDB
      Mongo Austin   February 15, 2011




                                         WYNNNETHERLAND
whoami
+
Two years ago...
x
    No SQL?


       x
MongoDB
          x
Let's just skip to here already!



x
One year ago
CTO of Amazon




NoSQL   Smackdown!
Today
is it web scale?
x
How do we get to here?
       x
x
Enlightenment
Almost
  ^
    Two years with
Our journey
TweetCongress.org
“We the Tweeple of the United
States, in order to form a more
perfect government, establish
communication, and promote
transparency do hereby tweet the
Congress of the United States of
America.”
and aggregator
                           ^
The idea: A Twitter directory for the US Congress
When does NOSQL make sense?
★ Your data is stored and retrieved mainly by primary key, without
  complex joins.
★ You have a non-trivial amount of data, and the thought of managing
  lots of RDBMS shards and replication failure scenarios gives you the fear.


http://www.metabrew.com/article/anti-rdbms-a-list-of-distributed-key-value-stores/
Key value stores
 Project Voldemort

                           me ver  y cool
 Ringo
 Scalaris
                        So                space
 Kai
                           ojects in this
 Dynomite
 MemcacheDB
                        pr
 ThruDB
 CouchDB
 Cassandra
 HBase
 Hypertable
 Redis
 Tokyo Cabinet/Tyrant
 Riak
 Neo4J
Tokyo Cabinet
CouchDB

Apache CouchDB is a distributed, fault-tolerant and
schema-free document-oriented database accessible via
a RESTful HTTP/JSON API.




http://couchdb.apache.org/
SQL                                             CouchDB

             Prede ned, explicit schema                            Dynamic, implicit schema



                                                          Collection of named documents with varying
               Uniform tables of data
                                                                           structure


      Normalized. Objects spread across tables.          Denormalized. Docs usually self contained. Data
               Duplication reduced.                                    often duplicated.


     Must know schema to read/write a complete
                                                                Must know only document name
                     object



         Dynamic queries of static schemas                     Static queries of dynamic schemas



        http://damienkatz.net/files/What is CouchDB.pdf
http://damienkatz.net/files/What is CouchDB.pdf
SQL                                           CouchDB

             Prede ned, explicit schema                           Dynamic, implicit schema



                                                         Collection of named documents with varying
               Uniform tables of data
                                                                          structure


      Normalized. Objects spread across tables.
               Duplication reduced.
                                               TheDenormalized. Docs usually selfdetails
                                                   devil'soften duplicated.contained. Data
                                                                 in the

     Must know schema to read/write a complete
                                                              Must know only document name
                     object



         Dynamic queries of static schemas                  Static queries of dynamic schemas



        http://damienkatz.net/files/What is CouchDB.pdf
http://damienkatz.net/files/What is CouchDB.pdf
why I
Mongo speaks JSON
Document Storage (BSON)                     B is for Binary

        { author: 'joe',
            created: Date('03-28-2009'),
            title: 'Yet another blog post',
            text: 'Here is the text...',
            tags: [ 'example', 'joe' ],
            comments: [ { author: 'jim', comment: 'I disagree' },
                        { author: 'nancy', comment: 'Good post' }
            ]
        }


     Sure wish JSON did this...


http://www.mongodb.org/display/DOCS/BSON
That looks like JSON
versatility
Runs like Hayes.
Hits like Mays.
Introducing
★ Built For Speedcan be very fast

★ Dynamic Queries and Indexes
★ Replication and Failover
★ Sharding
★ Map / Reduce
★ Geospatial stuffs
MongoDB is great for
 ★ Websites
                         Your own queryable API mirror
 ★ Caching
 ★ High volume, low value
 ★ High scalability                          stash the hash

 ★ Storage of program objects and JSON
Not as great for
 ★ Highly transactional
 ★ Financial stuffs
 ★ Problems requiring SQL
Installation
 ★ mkdir -p /data/db
 ★ download pre-built for OSX and unzip to /usr/local/
 ★ cp -R /usr/local/pathtomongo/bin /usr/local/bin

                                     Ruby driver for MongoDB

 ★ gem install mongo
                                           Native C
 ★ gem install mongo_ext                   extensions ( go turbo! )


 ★ gem install mongo_mapper
brew install mongodb
Contents of mongo/bin                 what's in the box?



 ★ mongod - The MongoDB server
 ★ mongo - the JavaScript interactive shell
 ★ mongoexport - export data as JSON or csv
 ★ mongoimport - As advertised
                                                                was?
 ★ mongodump - Like mysqldump        why? What did you think it


 ★ mongorestore - Restore from mongodump les
 ★ mongos - Auto-sharding module (getting better with every build)
Some new terms
When I say   think

 database     database
              Well that one isn't new...
Databases in MongoDB
 ★ Made up of multiple collections
 ★ Are created on-the- y when rst referenced
When I say    think

 collection    table
Collections in MongoDB
 ★ Schema-less    but typed!


 ★ For grouping documents into smaller query sets (speed)
 ★ Indexable by one or more key
 ★ Are created on-the- y when rst referenced
 ★ Capped collections: Fixed size, older records dropped after limit
   reached
When I say   think

 document     record or row
The Ruby ecosystem
The Ruby driver
Querying
db.collection.find({'first_name': 'John'}) # finds all Johns

db.collection.find({'first_name': /^wynn/i}) # regex

db.collection.find_first({'_id':1}) # finds first with _id of 1

db.collection.find({'age': {'$gte': 21}}) # finds possible drinkers

db.collection.find({'author.first_name':'John'}) # subdocument

db.collection.find({$where:'this.age >= 6 && this.age <= 18'})
More
  Querying
  $in, $nin, $all, $ne, $gt, $gte, $lt, $lte, $size, $where

  :fields (like :select in active record)

  :limit, :offset for pagination

  :sort ascending or descending [['foo', 1], ['bar', -1]]

  count and group (uses map/reduce)

  db.collection.mapReduce(mapfunction,reducefunction[,options]);
Updating
$inc, $set, $unset, $push, $pushAll, $addToSet,
$pop, $pull, $pullAll, $rename, $bit
akfast w it h
B re
      Nune maker
John
MongoMapper           from @jnunemaker

 ★ Mongo is not MySQL
 ★ DSL for modeling domain should also teach you Mongo
 ★ Now in version 0.8.6




  I voted for "Nunemapper"
Features
★ Typecasting
★ Callbacks (ActiveSupport Callbacks)
★ Validations
★ Connection and database can differ per document
★ Create and Update with single or multiple
★ Delete and Destroy and _all counterparts
                                         Be careful. Ordering can be tricky.
★ Find: id, ids, :all, : rst, :last
★ Associations
Example
class User
  include MongoMapper::Document
  key :name, String, :required => true, :length => 5..100
  key :email, String, :required => true, :index => true
  key :age, Integer, :numeric => true
  key :active, Boolean, :default => true

  one :address
  many :articles
end
                             Included as module, not subclassed
class Address
  include MongoMapper::Document
  key :street, String
  key :city, String
  key :state, String, :length => 2
  key :zip, Integer, :numeric => true, :length => 5
end
Queries
User.where(:age.gt   =>   27).sort(:age).all
User.where(:age.gt   =>   27).sort(:age.desc).all
User.where(:age.gt   =>   27).sort(:age).limit(1).all
User.where(:age.gt   =>   27).sort(:age).skip(1).limit(1).all
Scopes
class User
  include MongoMapper::Document

  # plain old vanilla scopes with fancy queries
  scope :johns,   where(:name => 'John')

  # plain old vanilla scopes with hashes
  scope :bills, :name => 'Bill'

  # dynamic scopes with parameters
  scope :by_name, lambda { |name| where(:name => name) }
  scope :by_ages, lambda { |low, high| where(:age.gte => low, :age.lte => high) }

  # Yep, even plain old methods work as long as they return a query
  def self.by_tag(tag)
    where(:tags => tag)
  end

  # You can even make a method that returns a scope
  def self.twenties; by_ages(20, 29) end

  key :name, String
  key :tags, Array
end
Scopes
# simple scopes
pp User.johns.first
pp User.bills.first

# scope with arg
pp User.by_name('Frank').first

# scope with two args
pp User.by_ages(20, 29).all

# chaining class methods on scopes
pp User.by_ages(20, 40).by_tag('ruby').all

# scope made using method that returns scope
pp User.twenties.all
Mongoid
Mongomatic
Mongomatic
require 'mongomatic'
 
class User < Mongomatic::Base
  def validate
    self.errors.add "name", "can't be empty" if self["name"].blank?
    self.errors.add "email", "can't be empty" if self["email"].blank?
  end
end
 
# set the db for all models:
Mongomatic.db = Mongo::Connection.new.db("mongomatic_test")
# or you can set it for a specific model:
User.db = Mongo::Connection.new.db("mongomatic_test_user")
 
Mongomatic
User.empty?
=> true
u = User.new(:name => "Ben")
=> #<user:0x00000100d0cbf8 @doc="{"name"=">"Ben"}, @removed=false>
u.valid?
=> false
u["email"] = "me@somewhere.com"
u.valid?
=> true
u.insert
=> BSON::ObjectId('4c32834f0218236321000001')
 
User.empty?
=> false
MongoDB is open source
Mongo runs in the cloud
#mongodb
How can you help?
 ★ We need an awesome admin GUI
 ★ Port some plugins (might get easier with ActiveModel support
   coming soon)
 ★ Build something cool
Lessons learned in production                      the fine print

 ★ The laws of computing are still in effect            Upserts FTW!
 ★ Indexes are important no matter what the salesman told ya about
   performance
 ★ Data modeling. Deep or Wide?     The answer is yes!


 ★ MongoDB and MongoMapper are in active development
                  Very responsive yet very volatile changes!
10gen
Get the backstory on
Questions?

    wynn@hp.com
     @pengwynn

More Related Content

What's hot

Developing CouchApps
Developing CouchAppsDeveloping CouchApps
Developing CouchAppswesthoff
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentationMario Noble
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax ...
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective,  Ajax ...The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective,  Ajax ...
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax ...Nicole Sullivan
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern PerlDave Cross
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Henry S
 
CSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingCSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingJames Cryer
 
Build your first MongoDB App in Ruby @ StrangeLoop 2013
Build your first MongoDB App in Ruby @ StrangeLoop 2013Build your first MongoDB App in Ruby @ StrangeLoop 2013
Build your first MongoDB App in Ruby @ StrangeLoop 2013Steven Francia
 
Framework agnostic application Will it fit with Symfony? - Symfony live warsa...
Framework agnostic application Will it fit with Symfony? - Symfony live warsa...Framework agnostic application Will it fit with Symfony? - Symfony live warsa...
Framework agnostic application Will it fit with Symfony? - Symfony live warsa...Dariusz Drobisz
 
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForgeAllura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForgeRick Copeland
 
Apache AVRO (Boston HUG, Jan 19, 2010)
Apache AVRO (Boston HUG, Jan 19, 2010)Apache AVRO (Boston HUG, Jan 19, 2010)
Apache AVRO (Boston HUG, Jan 19, 2010)Cloudera, Inc.
 
It's 2017, and I still want to sell you a graph database
It's 2017, and I still want to sell you a graph databaseIt's 2017, and I still want to sell you a graph database
It's 2017, and I still want to sell you a graph databaseSwanand Pagnis
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)Folio3 Software
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.Eugene Nor
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESSItai Koren
 
MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012Steven Francia
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHPRob Knight
 
WordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkWordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkExove
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 

What's hot (20)

Developing CouchApps
Developing CouchAppsDeveloping CouchApps
Developing CouchApps
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax ...
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective,  Ajax ...The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective,  Ajax ...
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax ...
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern Perl
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2
 
CSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingCSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y trying
 
Build your first MongoDB App in Ruby @ StrangeLoop 2013
Build your first MongoDB App in Ruby @ StrangeLoop 2013Build your first MongoDB App in Ruby @ StrangeLoop 2013
Build your first MongoDB App in Ruby @ StrangeLoop 2013
 
Framework agnostic application Will it fit with Symfony? - Symfony live warsa...
Framework agnostic application Will it fit with Symfony? - Symfony live warsa...Framework agnostic application Will it fit with Symfony? - Symfony live warsa...
Framework agnostic application Will it fit with Symfony? - Symfony live warsa...
 
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForgeAllura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForge
 
Apache AVRO (Boston HUG, Jan 19, 2010)
Apache AVRO (Boston HUG, Jan 19, 2010)Apache AVRO (Boston HUG, Jan 19, 2010)
Apache AVRO (Boston HUG, Jan 19, 2010)
 
It's 2017, and I still want to sell you a graph database
It's 2017, and I still want to sell you a graph databaseIt's 2017, and I still want to sell you a graph database
It's 2017, and I still want to sell you a graph database
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
Sass presentation
Sass presentationSass presentation
Sass presentation
 
MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
 
WordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkWordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a Framework
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 

Viewers also liked

GraphDay Stockholm - Fraud Prevention
GraphDay Stockholm - Fraud PreventionGraphDay Stockholm - Fraud Prevention
GraphDay Stockholm - Fraud PreventionNeo4j
 
Fraud detection, whiplash for cash scheme and Neo4j
Fraud detection, whiplash for cash scheme and Neo4jFraud detection, whiplash for cash scheme and Neo4j
Fraud detection, whiplash for cash scheme and Neo4jLinkurious
 
Mongo DB in gaming industry
Mongo DB in gaming industryMongo DB in gaming industry
Mongo DB in gaming industryDmitry Makarchuk
 
Bank Failures and Case Studies
Bank Failures and Case StudiesBank Failures and Case Studies
Bank Failures and Case StudiesZeeshan Azam
 
How to apply graph analytics for bank loan fraud detection?
How to apply graph analytics for bank loan fraud detection?How to apply graph analytics for bank loan fraud detection?
How to apply graph analytics for bank loan fraud detection?Linkurious
 
Fraud in the Banking Sector
Fraud in the Banking Sector Fraud in the Banking Sector
Fraud in the Banking Sector Venktesh Venke
 
Intro to Neo4j and Graph Databases
Intro to Neo4j and Graph DatabasesIntro to Neo4j and Graph Databases
Intro to Neo4j and Graph DatabasesNeo4j
 
Presentation on fraud prevention, detection & control
Presentation on fraud prevention, detection & controlPresentation on fraud prevention, detection & control
Presentation on fraud prevention, detection & controlDominic Sroda Korkoryi
 

Viewers also liked (10)

GraphDay Stockholm - Fraud Prevention
GraphDay Stockholm - Fraud PreventionGraphDay Stockholm - Fraud Prevention
GraphDay Stockholm - Fraud Prevention
 
Fraud detection, whiplash for cash scheme and Neo4j
Fraud detection, whiplash for cash scheme and Neo4jFraud detection, whiplash for cash scheme and Neo4j
Fraud detection, whiplash for cash scheme and Neo4j
 
Mongo DB in gaming industry
Mongo DB in gaming industryMongo DB in gaming industry
Mongo DB in gaming industry
 
Bank Failures and Case Studies
Bank Failures and Case StudiesBank Failures and Case Studies
Bank Failures and Case Studies
 
Dex: Introduction
Dex: IntroductionDex: Introduction
Dex: Introduction
 
How to apply graph analytics for bank loan fraud detection?
How to apply graph analytics for bank loan fraud detection?How to apply graph analytics for bank loan fraud detection?
How to apply graph analytics for bank loan fraud detection?
 
Fraud principles1
Fraud principles1Fraud principles1
Fraud principles1
 
Fraud in the Banking Sector
Fraud in the Banking Sector Fraud in the Banking Sector
Fraud in the Banking Sector
 
Intro to Neo4j and Graph Databases
Intro to Neo4j and Graph DatabasesIntro to Neo4j and Graph Databases
Intro to Neo4j and Graph Databases
 
Presentation on fraud prevention, detection & control
Presentation on fraud prevention, detection & controlPresentation on fraud prevention, detection & control
Presentation on fraud prevention, detection & control
 

Similar to MongoDB is the MashupDB

DynamoDB Gluecon 2012
DynamoDB Gluecon 2012DynamoDB Gluecon 2012
DynamoDB Gluecon 2012Appirio
 
Gluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDBGluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDBJeff Douglas
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataRoger Xia
 
NoSQL: Why, When, and How
NoSQL: Why, When, and HowNoSQL: Why, When, and How
NoSQL: Why, When, and HowBigBlueHat
 
Non Relational Databases
Non Relational DatabasesNon Relational Databases
Non Relational DatabasesChris Baglieri
 
JS App Architecture
JS App ArchitectureJS App Architecture
JS App ArchitectureCorey Butler
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxRoopaR36
 
Mongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMohan Rathour
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql DatabasePrashant Gupta
 
Navigating NoSQL in cloudy skies
Navigating NoSQL in cloudy skiesNavigating NoSQL in cloudy skies
Navigating NoSQL in cloudy skiesshnkr_rmchndrn
 
Introduction to NoSql
Introduction to NoSqlIntroduction to NoSql
Introduction to NoSqlOmid Vahdaty
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015Himanshu Desai
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRailsMike Dirolf
 
Hybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS ApplicationsHybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS ApplicationsSteven Francia
 

Similar to MongoDB is the MashupDB (20)

DynamoDB Gluecon 2012
DynamoDB Gluecon 2012DynamoDB Gluecon 2012
DynamoDB Gluecon 2012
 
Gluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDBGluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDB
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_data
 
Nosql seminar
Nosql seminarNosql seminar
Nosql seminar
 
NoSQL: Why, When, and How
NoSQL: Why, When, and HowNoSQL: Why, When, and How
NoSQL: Why, When, and How
 
Non Relational Databases
Non Relational DatabasesNon Relational Databases
Non Relational Databases
 
JS App Architecture
JS App ArchitectureJS App Architecture
JS App Architecture
 
MongoDB
MongoDBMongoDB
MongoDB
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
 
Mongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorial
 
No sq lv1_0
No sq lv1_0No sq lv1_0
No sq lv1_0
 
NoSQL
NoSQLNoSQL
NoSQL
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql Database
 
Mongo db
Mongo dbMongo db
Mongo db
 
Navigating NoSQL in cloudy skies
Navigating NoSQL in cloudy skiesNavigating NoSQL in cloudy skies
Navigating NoSQL in cloudy skies
 
Introduction to NoSql
Introduction to NoSqlIntroduction to NoSql
Introduction to NoSql
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015
 
NoSQL, which way to go?
NoSQL, which way to go?NoSQL, which way to go?
NoSQL, which way to go?
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRails
 
Hybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS ApplicationsHybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS Applications
 

More from Wynn Netherland

Accelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gemAccelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gemWynn Netherland
 
Your government is Mashed UP!
Your government is Mashed UP!Your government is Mashed UP!
Your government is Mashed UP!Wynn Netherland
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperWynn Netherland
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3 Wynn Netherland
 
America, your congress is Mashed UP!
America, your congress is Mashed UP!America, your congress is Mashed UP!
America, your congress is Mashed UP!Wynn Netherland
 
CSS Metaframeworks: King of all @media
CSS Metaframeworks: King of all @mediaCSS Metaframeworks: King of all @media
CSS Metaframeworks: King of all @mediaWynn Netherland
 
Build An App Start A Movement
Build An App Start A MovementBuild An App Start A Movement
Build An App Start A MovementWynn Netherland
 
Javascript And Ruby Frameworks
Javascript And Ruby FrameworksJavascript And Ruby Frameworks
Javascript And Ruby FrameworksWynn Netherland
 
Free(ish) Tools For Virtual Teams
Free(ish) Tools For Virtual TeamsFree(ish) Tools For Virtual Teams
Free(ish) Tools For Virtual TeamsWynn Netherland
 

More from Wynn Netherland (11)

Accelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gemAccelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gem
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Your government is Mashed UP!
Your government is Mashed UP!Your government is Mashed UP!
Your government is Mashed UP!
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS Developer
 
JSON and the APInauts
JSON and the APInautsJSON and the APInauts
JSON and the APInauts
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 
America, your congress is Mashed UP!
America, your congress is Mashed UP!America, your congress is Mashed UP!
America, your congress is Mashed UP!
 
CSS Metaframeworks: King of all @media
CSS Metaframeworks: King of all @mediaCSS Metaframeworks: King of all @media
CSS Metaframeworks: King of all @media
 
Build An App Start A Movement
Build An App Start A MovementBuild An App Start A Movement
Build An App Start A Movement
 
Javascript And Ruby Frameworks
Javascript And Ruby FrameworksJavascript And Ruby Frameworks
Javascript And Ruby Frameworks
 
Free(ish) Tools For Virtual Teams
Free(ish) Tools For Virtual TeamsFree(ish) Tools For Virtual Teams
Free(ish) Tools For Virtual Teams
 

Recently uploaded

So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 

Recently uploaded (20)

So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 

MongoDB is the MashupDB

  • 1. Stash the Hash! MongoDB is the MashupDB Mongo Austin February 15, 2011 WYNNNETHERLAND
  • 3. +
  • 4.
  • 6.
  • 7. x No SQL? x
  • 9. Let's just skip to here already! x
  • 11. CTO of Amazon NoSQL Smackdown!
  • 12. Today
  • 13. is it web scale?
  • 14. x
  • 15. How do we get to here? x x
  • 17. Almost ^ Two years with
  • 20. “We the Tweeple of the United States, in order to form a more perfect government, establish communication, and promote transparency do hereby tweet the Congress of the United States of America.”
  • 21. and aggregator ^ The idea: A Twitter directory for the US Congress
  • 22.
  • 23. When does NOSQL make sense? ★ Your data is stored and retrieved mainly by primary key, without complex joins. ★ You have a non-trivial amount of data, and the thought of managing lots of RDBMS shards and replication failure scenarios gives you the fear. http://www.metabrew.com/article/anti-rdbms-a-list-of-distributed-key-value-stores/
  • 24. Key value stores Project Voldemort me ver y cool Ringo Scalaris So space Kai ojects in this Dynomite MemcacheDB pr ThruDB CouchDB Cassandra HBase Hypertable Redis Tokyo Cabinet/Tyrant Riak Neo4J
  • 26.
  • 27. CouchDB Apache CouchDB is a distributed, fault-tolerant and schema-free document-oriented database accessible via a RESTful HTTP/JSON API. http://couchdb.apache.org/
  • 28. SQL CouchDB Prede ned, explicit schema Dynamic, implicit schema Collection of named documents with varying Uniform tables of data structure Normalized. Objects spread across tables. Denormalized. Docs usually self contained. Data Duplication reduced. often duplicated. Must know schema to read/write a complete Must know only document name object Dynamic queries of static schemas Static queries of dynamic schemas http://damienkatz.net/files/What is CouchDB.pdf http://damienkatz.net/files/What is CouchDB.pdf
  • 29. SQL CouchDB Prede ned, explicit schema Dynamic, implicit schema Collection of named documents with varying Uniform tables of data structure Normalized. Objects spread across tables. Duplication reduced. TheDenormalized. Docs usually selfdetails devil'soften duplicated.contained. Data in the Must know schema to read/write a complete Must know only document name object Dynamic queries of static schemas Static queries of dynamic schemas http://damienkatz.net/files/What is CouchDB.pdf http://damienkatz.net/files/What is CouchDB.pdf
  • 30. why I
  • 32. Document Storage (BSON) B is for Binary { author: 'joe', created: Date('03-28-2009'), title: 'Yet another blog post', text: 'Here is the text...', tags: [ 'example', 'joe' ], comments: [ { author: 'jim', comment: 'I disagree' }, { author: 'nancy', comment: 'Good post' } ] } Sure wish JSON did this... http://www.mongodb.org/display/DOCS/BSON
  • 35.
  • 36. Runs like Hayes. Hits like Mays.
  • 37. Introducing ★ Built For Speedcan be very fast ★ Dynamic Queries and Indexes ★ Replication and Failover ★ Sharding ★ Map / Reduce ★ Geospatial stuffs
  • 38. MongoDB is great for ★ Websites Your own queryable API mirror ★ Caching ★ High volume, low value ★ High scalability stash the hash ★ Storage of program objects and JSON
  • 39. Not as great for ★ Highly transactional ★ Financial stuffs ★ Problems requiring SQL
  • 40. Installation ★ mkdir -p /data/db ★ download pre-built for OSX and unzip to /usr/local/ ★ cp -R /usr/local/pathtomongo/bin /usr/local/bin Ruby driver for MongoDB ★ gem install mongo Native C ★ gem install mongo_ext extensions ( go turbo! ) ★ gem install mongo_mapper
  • 42. Contents of mongo/bin what's in the box? ★ mongod - The MongoDB server ★ mongo - the JavaScript interactive shell ★ mongoexport - export data as JSON or csv ★ mongoimport - As advertised was? ★ mongodump - Like mysqldump why? What did you think it ★ mongorestore - Restore from mongodump les ★ mongos - Auto-sharding module (getting better with every build)
  • 44. When I say think database database Well that one isn't new...
  • 45. Databases in MongoDB ★ Made up of multiple collections ★ Are created on-the- y when rst referenced
  • 46. When I say think collection table
  • 47. Collections in MongoDB ★ Schema-less but typed! ★ For grouping documents into smaller query sets (speed) ★ Indexable by one or more key ★ Are created on-the- y when rst referenced ★ Capped collections: Fixed size, older records dropped after limit reached
  • 48. When I say think document record or row
  • 51. Querying db.collection.find({'first_name': 'John'}) # finds all Johns db.collection.find({'first_name': /^wynn/i}) # regex db.collection.find_first({'_id':1}) # finds first with _id of 1 db.collection.find({'age': {'$gte': 21}}) # finds possible drinkers db.collection.find({'author.first_name':'John'}) # subdocument db.collection.find({$where:'this.age >= 6 && this.age <= 18'})
  • 52. More Querying $in, $nin, $all, $ne, $gt, $gte, $lt, $lte, $size, $where :fields (like :select in active record) :limit, :offset for pagination :sort ascending or descending [['foo', 1], ['bar', -1]] count and group (uses map/reduce) db.collection.mapReduce(mapfunction,reducefunction[,options]);
  • 53. Updating $inc, $set, $unset, $push, $pushAll, $addToSet, $pop, $pull, $pullAll, $rename, $bit
  • 54.
  • 55. akfast w it h B re Nune maker John
  • 56. MongoMapper from @jnunemaker ★ Mongo is not MySQL ★ DSL for modeling domain should also teach you Mongo ★ Now in version 0.8.6 I voted for "Nunemapper"
  • 57. Features ★ Typecasting ★ Callbacks (ActiveSupport Callbacks) ★ Validations ★ Connection and database can differ per document ★ Create and Update with single or multiple ★ Delete and Destroy and _all counterparts Be careful. Ordering can be tricky. ★ Find: id, ids, :all, : rst, :last ★ Associations
  • 58. Example class User include MongoMapper::Document key :name, String, :required => true, :length => 5..100 key :email, String, :required => true, :index => true key :age, Integer, :numeric => true key :active, Boolean, :default => true one :address many :articles end Included as module, not subclassed class Address include MongoMapper::Document key :street, String key :city, String key :state, String, :length => 2 key :zip, Integer, :numeric => true, :length => 5 end
  • 59. Queries User.where(:age.gt => 27).sort(:age).all User.where(:age.gt => 27).sort(:age.desc).all User.where(:age.gt => 27).sort(:age).limit(1).all User.where(:age.gt => 27).sort(:age).skip(1).limit(1).all
  • 60. Scopes class User include MongoMapper::Document # plain old vanilla scopes with fancy queries scope :johns, where(:name => 'John') # plain old vanilla scopes with hashes scope :bills, :name => 'Bill' # dynamic scopes with parameters scope :by_name, lambda { |name| where(:name => name) } scope :by_ages, lambda { |low, high| where(:age.gte => low, :age.lte => high) } # Yep, even plain old methods work as long as they return a query def self.by_tag(tag) where(:tags => tag) end # You can even make a method that returns a scope def self.twenties; by_ages(20, 29) end key :name, String key :tags, Array end
  • 61. Scopes # simple scopes pp User.johns.first pp User.bills.first # scope with arg pp User.by_name('Frank').first # scope with two args pp User.by_ages(20, 29).all # chaining class methods on scopes pp User.by_ages(20, 40).by_tag('ruby').all # scope made using method that returns scope pp User.twenties.all
  • 64. Mongomatic require 'mongomatic'   class User < Mongomatic::Base   def validate     self.errors.add "name", "can't be empty" if self["name"].blank?     self.errors.add "email", "can't be empty" if self["email"].blank?   end end   # set the db for all models: Mongomatic.db = Mongo::Connection.new.db("mongomatic_test") # or you can set it for a specific model: User.db = Mongo::Connection.new.db("mongomatic_test_user")  
  • 65. Mongomatic User.empty? => true u = User.new(:name => "Ben") => #<user:0x00000100d0cbf8 @doc="{"name"=">"Ben"}, @removed=false> u.valid? => false u["email"] = "me@somewhere.com" u.valid? => true u.insert => BSON::ObjectId('4c32834f0218236321000001')   User.empty? => false
  • 66. MongoDB is open source
  • 67. Mongo runs in the cloud
  • 69. How can you help? ★ We need an awesome admin GUI ★ Port some plugins (might get easier with ActiveModel support coming soon) ★ Build something cool
  • 70. Lessons learned in production the fine print ★ The laws of computing are still in effect Upserts FTW! ★ Indexes are important no matter what the salesman told ya about performance ★ Data modeling. Deep or Wide? The answer is yes! ★ MongoDB and MongoMapper are in active development Very responsive yet very volatile changes!
  • 71. 10gen
  • 73. Questions? wynn@hp.com @pengwynn