SlideShare una empresa de Scribd logo
1 de 54
Steve Klabnik
Pittsburgh Ruby Brigade
        October 7, 2010
“The best features of
Document Databases,
  Key-Value Stores,
  and RDBMSes.”
Document Database
JSON
BSON
http://hackety-hack.com/
http://github.com/hacketyhack/hackety-hack.com
post = {
  "_id" : ObjectId("4c67892ba8d8770eb8000003"),
  "title" : "Welcome to the Hackety Site!",
  "body" : "This is an intial post, so that you can see how
everything looks. ",
  "updated_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)"
  "created_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)",
  "comments" : [
     {
       "body" : "This post is awesome! I've never seen such
insightful writing!!",
       "author" : "somebody",
       "_id" : ObjectId("4c67892ba8d8770eb8000004"),
       "author_email" : "somebody@example.com"
     }
  ],
}
post = {
  "_id" : ObjectId("4c67892ba8d8770eb8000003"),
  "title" : "Welcome to the Hackety Site!",
  "body" : "This is an intial post, so that you can see how
everything looks. ",
  "updated_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)"
  "created_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)",
  "comments" : [
     {
       "body" : "This post is awesome! I've never seen such
insightful writing!!",
       "author" : "somebody",
       "_id" : ObjectId("4c67892ba8d8770eb8000004"),
       "author_email" : "somebody@example.com"
     }
  ],
}
post = {
  "_id" : ObjectId("4c67892ba8d8770eb8000003"),
  "title" : "Welcome to the Hackety Site!",
  "body" : "This is an intial post, so that you can see how
everything looks. ",
  "updated_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)"
  "created_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)",
  "comments" : [
     {
       "body" : "This post is awesome! I've never seen such
insightful writing!!",
       "author" : "somebody",
       "_id" : ObjectId("4c67892ba8d8770eb8000004"),
       "author_email" : "somebody@example.com"
     }
  ],
}
post = {
  "_id" : ObjectId("4c67892ba8d8770eb8000003"),
  "title" : "Welcome to the Hackety Site!",
  "body" : "This is an intial post, so that you can see how
everything looks. ",
  "updated_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)"
  "created_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)",
  "comments" : [
     {
       "body" : "This post is awesome! I've never seen such
insightful writing!!",
       "author" : "somebody",
       "_id" : ObjectId("4c67892ba8d8770eb8000004"),
       "author_email" : "somebody@example.com"
     }
  ],
}
Look, Ma! No Schema!
post = {
  "_id" : ObjectId("4c67892ba8d8770eb8000004"),
  "title" : "Here’s a cool update!",
  "body" : "This is an explanation of all the new features!",
  "updated_at" : "Sun Aug 15 2010 02:29:60 GMT-0400 (EDT)"
  "created_at" : "Sun Aug 15 2010 02:29:60 GMT-0400 (EDT)",
}
$ mongo
MongoDB shell version: 1.6.3
connecting to: test
> use hackety-development;
switched to db hackety-development
> show collections;
discussions
hackers
messages
posts
programs
system.indexes
users
> db.posts.find();
{ "_id" : ObjectId("...
> db.users.find({“username”:”steve”})
> db.posts.find({“tags”:{$in:[“ruby”, “rails”]}})
JavaScript
> f = function(x) { return x + 1; }
function (x) {
   return x + 1;
}
> f(2);
3
JSON == {}
JSON == {}
(1.9.x)
$ rvm use 1.9.2

info: Using ruby 1.9.2 p0
$ irb
ruby-1.9.2-p0 > {lol: "wut"}
 => {:lol=>"wut"}
ruby-1.9.2-p0 >
“Why I think Mongo is to
                     Databases what Rails was
                         to Frameworks”
http://railstips.org/blog/archives/2009/12/18/why-i-think-mongo-is-to-databases-what-rails-was-to-frameworks/
Map / Reduce
Map / Reduce
functional programming concepts
Map: Enumerable#map
map :: (a -> b) -> [a] -> [b]
    (transforms one list into another list
               via a function)
Reduce: Enumerable#inject
foldl :: (a -> b -> a) -> a -> [b] -> a
           (takes a function with two arguments,
         a starting point, and a list, and repeatedly
       calls that function until only one value is left)
functional programming concepts
distributed computing
$ ./mongo
> db.things.insert(   { _id : 1, tags : ['dog', 'cat'] } );
> db.things.insert(   { _id : 2, tags : ['cat'] } );
> db.things.insert(   { _id : 3, tags : ['mouse', 'cat',
'dog'] } );
> db.things.insert(   { _id : 4, tags : []   } );

> // map function
> m = function(){
...    this.tags.forEach(
...        function(z){
...            emit( z , { count : 1 } );
...        }
...    );
...};

> // reduce function
> r = function( key , values ){
...    var total = 0;
...    for ( var i=0; i<values.length; i++ )
...        total += values[i].count;
...    return { count : total };
...};

> res = db.things.mapReduce(m,r);
> res
{"timeMillis.emit" : 9 , "result" : "mr.things.
1254430454.3" ,
 "numObjects" : 4 , "timeMillis" : 9 , "errmsg" : "" , "ok" :
0}

> db[res.result].find()
{"_id" : "cat" , "value" : {"count" : 3}}
{"_id" : "dog" , "value" : {"count" : 2}}
{"_id" : "mouse" , "value" : {"count" : 1}}
class Post
  include MongoMapper::Document

  key :title, String
  key :body, String

  key :slug, String

  many :comments
  timestamps!
end
“Software Engineering is the art of
            choosing
  the correct set of tradeoffs”-Me
# 1000
 mongokit django_mongokit.mongodb
 Creating 1000 talks took 0.957674026489
seconds
 Editing 1000 talks took 1.60552191734 seconds
 Deleting 1000 talks took 1.28869891167
seconds
 IN TOTAL 3.8518948555 seconds

 sql django.db.backends.postgresql_psycopg2
 Creating 1000 talks took 8.57405209541
seconds
 Editing 1000 talks took 14.8357069492 seconds
 Deleting 1000 talks took 11.9729249477
seconds




                              http://www.peterbe.com/plog/speed-test-between-django_mongokit-and-postgresql_psycopg2
Rich Documents == Less Querying
ACID
(Atomicity, Consistency, Isolation, Durability)
Durability, Schmerability
         (single server)
32 bit?
Use the right tool
Thanks
           @steveklabnik
       http://steveklabnik.com/
http://www.slideshare.net/SteveKlabnik

Más contenido relacionado

La actualidad más candente

PostgreSQLからMongoDBへ
PostgreSQLからMongoDBへPostgreSQLからMongoDBへ
PostgreSQLからMongoDBへBasuke Suzuki
 
Mongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsMongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsPallavi Srivastava
 
You Don't Need Lodash
You Don't Need Lodash You Don't Need Lodash
You Don't Need Lodash UpsideTravel
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
Logging your node.js application
Logging your node.js applicationLogging your node.js application
Logging your node.js applicationMd. Sohel Rana
 
NoSQL & MongoDB
NoSQL & MongoDBNoSQL & MongoDB
NoSQL & MongoDBShuai Liu
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway ichikaway
 
Mongo db modifiers
Mongo db modifiersMongo db modifiers
Mongo db modifierszarigatongy
 
The Ring programming language version 1.5.4 book - Part 40 of 185
The Ring programming language version 1.5.4 book - Part 40 of 185The Ring programming language version 1.5.4 book - Part 40 of 185
The Ring programming language version 1.5.4 book - Part 40 of 185Mahmoud Samir Fayed
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationMongoDB
 
PuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with PuppetPuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with PuppetWalter Heck
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensionserwanl
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHPHow to use MongoDB with CakePHP
How to use MongoDB with CakePHPichikaway
 
Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発swdyh
 

La actualidad más candente (20)

PostgreSQLからMongoDBへ
PostgreSQLからMongoDBへPostgreSQLからMongoDBへ
PostgreSQLからMongoDBへ
 
Mongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsMongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node js
 
You Don't Need Lodash
You Don't Need Lodash You Don't Need Lodash
You Don't Need Lodash
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Logging your node.js application
Logging your node.js applicationLogging your node.js application
Logging your node.js application
 
NoSQL & MongoDB
NoSQL & MongoDBNoSQL & MongoDB
NoSQL & MongoDB
 
Couchdb
CouchdbCouchdb
Couchdb
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
 
Q
QQ
Q
 
Mongo db modifiers
Mongo db modifiersMongo db modifiers
Mongo db modifiers
 
The Ring programming language version 1.5.4 book - Part 40 of 185
The Ring programming language version 1.5.4 book - Part 40 of 185The Ring programming language version 1.5.4 book - Part 40 of 185
The Ring programming language version 1.5.4 book - Part 40 of 185
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB Application
 
PuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with PuppetPuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with Puppet
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Couchdb
CouchdbCouchdb
Couchdb
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Play á la Rails
Play á la RailsPlay á la Rails
Play á la Rails
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHPHow to use MongoDB with CakePHP
How to use MongoDB with CakePHP
 
Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発
 

Similar a MongoDB

Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDBNate Abele
 
Marc s01 e02-crud-database
Marc s01 e02-crud-databaseMarc s01 e02-crud-database
Marc s01 e02-crud-databaseMongoDB
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...MongoDB
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data ModelingDATAVERSITY
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in goYusuke Kita
 
Schema design
Schema designSchema design
Schema designchristkv
 
Schema Design with MongoDB
Schema Design with MongoDBSchema Design with MongoDB
Schema Design with MongoDBrogerbodamer
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBantoinegirbal
 
2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introductionantoinegirbal
 
MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011Steven Francia
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in DocumentsMongoDB
 
MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009Mike Dirolf
 
Back to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsBack to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsJoe Drumgoole
 
JavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptJavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptLaurence Svekis ✔
 
Building Your First MongoDB Application
Building Your First MongoDB ApplicationBuilding Your First MongoDB Application
Building Your First MongoDB ApplicationTugdual Grall
 
Webinar: Build an Application Series - Session 2 - Getting Started
Webinar: Build an Application Series - Session 2 - Getting StartedWebinar: Build an Application Series - Session 2 - Getting Started
Webinar: Build an Application Series - Session 2 - Getting StartedMongoDB
 
MongoDB & Mongoid with Rails
MongoDB & Mongoid with RailsMongoDB & Mongoid with Rails
MongoDB & Mongoid with RailsJustin Smestad
 

Similar a MongoDB (20)

Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
Mongo db presentation
Mongo db presentationMongo db presentation
Mongo db presentation
 
Latinoware
LatinowareLatinoware
Latinoware
 
Marc s01 e02-crud-database
Marc s01 e02-crud-databaseMarc s01 e02-crud-database
Marc s01 e02-crud-database
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling
 
greenDAO
greenDAOgreenDAO
greenDAO
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in go
 
Schema design
Schema designSchema design
Schema design
 
Schema Design with MongoDB
Schema Design with MongoDBSchema Design with MongoDB
Schema Design with MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction
 
MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in Documents
 
MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009
 
Back to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsBack to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in Documents
 
JavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptJavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScript
 
Building Your First MongoDB Application
Building Your First MongoDB ApplicationBuilding Your First MongoDB Application
Building Your First MongoDB Application
 
Webinar: Build an Application Series - Session 2 - Getting Started
Webinar: Build an Application Series - Session 2 - Getting StartedWebinar: Build an Application Series - Session 2 - Getting Started
Webinar: Build an Application Series - Session 2 - Getting Started
 
MongoDB & Mongoid with Rails
MongoDB & Mongoid with RailsMongoDB & Mongoid with Rails
MongoDB & Mongoid with Rails
 

Último

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

MongoDB

  • 1. Steve Klabnik Pittsburgh Ruby Brigade October 7, 2010
  • 2. “The best features of Document Databases, Key-Value Stores, and RDBMSes.”
  • 4.
  • 8. post = { "_id" : ObjectId("4c67892ba8d8770eb8000003"), "title" : "Welcome to the Hackety Site!", "body" : "This is an intial post, so that you can see how everything looks. ", "updated_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)" "created_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)", "comments" : [ { "body" : "This post is awesome! I've never seen such insightful writing!!", "author" : "somebody", "_id" : ObjectId("4c67892ba8d8770eb8000004"), "author_email" : "somebody@example.com" } ], }
  • 9. post = { "_id" : ObjectId("4c67892ba8d8770eb8000003"), "title" : "Welcome to the Hackety Site!", "body" : "This is an intial post, so that you can see how everything looks. ", "updated_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)" "created_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)", "comments" : [ { "body" : "This post is awesome! I've never seen such insightful writing!!", "author" : "somebody", "_id" : ObjectId("4c67892ba8d8770eb8000004"), "author_email" : "somebody@example.com" } ], }
  • 10. post = { "_id" : ObjectId("4c67892ba8d8770eb8000003"), "title" : "Welcome to the Hackety Site!", "body" : "This is an intial post, so that you can see how everything looks. ", "updated_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)" "created_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)", "comments" : [ { "body" : "This post is awesome! I've never seen such insightful writing!!", "author" : "somebody", "_id" : ObjectId("4c67892ba8d8770eb8000004"), "author_email" : "somebody@example.com" } ], }
  • 11. post = { "_id" : ObjectId("4c67892ba8d8770eb8000003"), "title" : "Welcome to the Hackety Site!", "body" : "This is an intial post, so that you can see how everything looks. ", "updated_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)" "created_at" : "Sun Aug 15 2010 02:28:59 GMT-0400 (EDT)", "comments" : [ { "body" : "This post is awesome! I've never seen such insightful writing!!", "author" : "somebody", "_id" : ObjectId("4c67892ba8d8770eb8000004"), "author_email" : "somebody@example.com" } ], }
  • 12. Look, Ma! No Schema!
  • 13. post = { "_id" : ObjectId("4c67892ba8d8770eb8000004"), "title" : "Here’s a cool update!", "body" : "This is an explanation of all the new features!", "updated_at" : "Sun Aug 15 2010 02:29:60 GMT-0400 (EDT)" "created_at" : "Sun Aug 15 2010 02:29:60 GMT-0400 (EDT)", }
  • 14. $ mongo MongoDB shell version: 1.6.3 connecting to: test > use hackety-development; switched to db hackety-development > show collections; discussions hackers messages posts programs system.indexes users > db.posts.find(); { "_id" : ObjectId("...
  • 18. > f = function(x) { return x + 1; } function (x) { return x + 1; } > f(2); 3
  • 21.
  • 23. $ rvm use 1.9.2 info: Using ruby 1.9.2 p0 $ irb ruby-1.9.2-p0 > {lol: "wut"} => {:lol=>"wut"} ruby-1.9.2-p0 >
  • 24. “Why I think Mongo is to Databases what Rails was to Frameworks” http://railstips.org/blog/archives/2009/12/18/why-i-think-mongo-is-to-databases-what-rails-was-to-frameworks/
  • 25.
  • 28.
  • 31. map :: (a -> b) -> [a] -> [b] (transforms one list into another list via a function)
  • 33. foldl :: (a -> b -> a) -> a -> [b] -> a (takes a function with two arguments, a starting point, and a list, and repeatedly calls that function until only one value is left)
  • 36. $ ./mongo > db.things.insert( { _id : 1, tags : ['dog', 'cat'] } ); > db.things.insert( { _id : 2, tags : ['cat'] } ); > db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } ); > db.things.insert( { _id : 4, tags : [] } ); > // map function > m = function(){ ... this.tags.forEach( ... function(z){ ... emit( z , { count : 1 } ); ... } ... ); ...}; > // reduce function > r = function( key , values ){ ... var total = 0; ... for ( var i=0; i<values.length; i++ ) ... total += values[i].count; ... return { count : total }; ...}; > res = db.things.mapReduce(m,r); > res {"timeMillis.emit" : 9 , "result" : "mr.things. 1254430454.3" , "numObjects" : 4 , "timeMillis" : 9 , "errmsg" : "" , "ok" : 0} > db[res.result].find() {"_id" : "cat" , "value" : {"count" : 3}} {"_id" : "dog" , "value" : {"count" : 2}} {"_id" : "mouse" , "value" : {"count" : 1}}
  • 37.
  • 38.
  • 39. class Post   include MongoMapper::Document   key :title, String   key :body, String   key :slug, String   many :comments   timestamps! end
  • 40.
  • 41. “Software Engineering is the art of choosing the correct set of tradeoffs”-Me
  • 42.
  • 43.
  • 44. # 1000 mongokit django_mongokit.mongodb Creating 1000 talks took 0.957674026489 seconds Editing 1000 talks took 1.60552191734 seconds Deleting 1000 talks took 1.28869891167 seconds IN TOTAL 3.8518948555 seconds sql django.db.backends.postgresql_psycopg2 Creating 1000 talks took 8.57405209541 seconds Editing 1000 talks took 14.8357069492 seconds Deleting 1000 talks took 11.9729249477 seconds http://www.peterbe.com/plog/speed-test-between-django_mongokit-and-postgresql_psycopg2
  • 45. Rich Documents == Less Querying
  • 46.
  • 48. Durability, Schmerability (single server)
  • 50.
  • 51.
  • 53.
  • 54. Thanks @steveklabnik http://steveklabnik.com/ http://www.slideshare.net/SteveKlabnik

Notas del editor