SlideShare a Scribd company logo
MongoDB
(from “humongous”)




     Wouter de Vos – 2011-10-31
What is MongoDB?

•   A No-SQL database

•   Document oriented

•   Open Source

•   Written in C++
Document Oriented?

•   Documents are stored in collections   > db.posts.findOne()
                                          {
                                            _id : ObjectId("4e77bb3b8a3e000000004f7a"),
                                            when : Date("2011-09-19T02:10:11.3Z",
                                            author : "alex",


•
                                            title : "No Free Lunch",
    No JOINS: embedded                      text : "This is the text of the post. It could be very long.",
                                            tags : [ "business", "ramblings" ],
                                            votes : 5,
                                            voters : [ "jane", "joe", "spencer", "phyllis", "li" ],
                                            comments : [


•
                                              { who : "jane", when : Date("2011-09-19T04:00:10.112Z"),
    No JOINS: linked                            comment : "I agree." },
                                              { who : "meghan", when : Date("2011-09-20T14:36:06.958Z"),
                                                comment : "You must be joking. etc etc ..." }
                                            ]
                                          }
Document Oriented?

•   Documents are stored in collections   > db.posts.findOne()
                                          {
                                            _id : ObjectId("4e77bb3b8a3e000000004f7a"),
                                            when : Date("2011-09-19T02:10:11.3Z",
                                            author : "alex",


•
                                            title : "No Free Lunch",
    No JOINS: embedded                      text : "This is the text of the post. It could be very long.",
                                            tags : [ "business", "ramblings" ],
                                            votes : 5,
                                            voters : [ "jane", "joe", "spencer", "phyllis", "li" ],
                                            comments : [


•
                                              { who : "jane", when : Date("2011-09-19T04:00:10.112Z"),
    No JOINS: linked                            comment : "I agree." },
                                              { who : "meghan", when : Date("2011-09-20T14:36:06.958Z"),
                                                comment : "You must be joking. etc etc ..." }
                                            ]
                                          }
Document Oriented?

•   Documents are stored in collections
                                                      > db.posts.findOne()


•
                                                      {
    No JOINS: embedded                                  _id : ObjectId("4e77bb3b8a3e000000004f7a"),
                                                        when : Date("2011-09-19T02:10:11.3Z",
                                                        author : "alex",
                                                        title : "No Free Lunch",
                                                        text : "This is the text of the post. It could be very long.",


•
                                                        tags : [ "business", "ramblings" ],
    No JOINS: linked                                    votes : 5,
                                                        voters : [ "jane", "joe", "spencer", "phyllis", "li" ],
                                                        comments : [
                                                          { who : "jane", when : Date("2011-09-19T04:00:10.112Z"),
                                                            comment : "I agree." },


    •
                                                          { who : "meghan", when : Date("2011-09-20T14:36:06.958Z"),
        links are references to other documents and     ]
                                                            comment : "You must be joking. etc etc ..." }

        are processed by the client.                  }
Cool features
                                   > db.invoices.find()
                                   {

•   Schemaless
                                      _id : ObjectId("4e77bb3b8a3e000000004f7a"),
                                      client: "Johnson",
                                      hosting: {
                                         per: "month",


•
                                         price: 100,
    Atomic operations                 },
                                         amount: 12,

                                      development: {
                                         per: "hour",

•   Map/Reduce
                                      }
                                         price: 120,
                                         amount: 80

                                   },

•
                                   {
    Fast, in-place updates            _id : ObjectId("4e77bb3b8a3e000000005f7a"),
                                      client: "Black",
                                      development: {
                                         per: "hour",

•   GridFS
                                      }
                                         price: 120,
                                         amount: 30

                                   },
Cool features
•   Schemaless                     atomically {
                                     if( doc.credits > 5 ) {
                                       doc.credits -= 5;
•   Atomic operations                  doc.debits += 5;
                                     }
                                   }
•   Map/Reduce


•   Fast, in-place updates


•   GridFS
Cool features
                                 // Document example
                                 { username: "jones",
                                   likes: 20,
                                   text: "Hello world!"

•   Schemaless                   }

                                 // Map
                                 function() {

•   Atomic operations            }
                                   emit( this.username, {count: 1, likes: this.likes} );


                                 // Reduce

•
                                 function(key, values) {
    Map/Reduce                     var result = {count: 0, likes: 0};

                                     values.forEach(function(value) {
                                       result.count += value.count;

•   Fast, in-place updates             result.likes += value.likes;
                                     });

                                     return result;

•
                                 }
    GridFS
                                 // Result
                                 { count: 10, likes: 247 }
Cool features
•   Schemaless


•   Atomic operations
                               // In place update
                               db.recipes.update(

•   Map/Reduce
                               )
                                   {'_id': recipe_id, 'voters': {'$ne': user_id}},
                                   {'$inc': {'votes': 1}, '$push': {'voters': user_id}}




•   Fast, in-place updates


•   GridFS
Cool features
•   Schemaless


•   Atomic operations              The GridFS spec provides a mechanism for
                                transparently dividing a large file among multiple

•   Map/Reduce
                               documents. This allows us to efficiently store large
                                objects, and in the case of especially large files,
                                 such as videos, permits range operations (e.g.,
•   Fast, in-place updates           fetching only the first N bytes of a file).


•   GridFS
Querying
• // A post with title “Mongo”
  db.posts.find({'title': 'Mongo'})


• // All posts about tennis, but without comments
  db.posts.find( { tags : 'tennis' }, { comments : 0 } );


• // last 5 comments
  db.posts.find({}, {comments:{'$slice': -5}})


• // just the likes of the comments
  db.posts.find({}, {'comments.$.likes': 1}
Use it for

•   It’s schemaless features (e.g. for prototyping)

•   It’s horizontal scalability (with auto-sharding)

•   To store and stream large files (with gridfs)

•   To make ultra-fast, single query updates
Cucumber
Scenarios for browser testing
Feature: User Registration and Logging in
  A User should be able to create an account.
  A User should be able to log in with a new account.
  A User should be able to create a profile after logging in for the first time.

  Scenario: Registration with a normal account.
    Given I sign up as a new user with email@example.com/secret
    Then I should be signed in
    And I sign out

  Scenario: Log in with a new account
    Given I sign up as a new user with email@example.com/secret
    Then I should be signed in
    Then I sign out
    And I sign in with email@example.com/secret
    Then I should be signed in
    And I sign out

  Scenario: Create a profile with a new account
    Given I sign in as a new user
    Then I should see "create your profile"
    And I fill in "profile_name" with "My Name"
    And I fill in "profile_about" with "I am a long green vegetable that goes well with salads."
    And I select an avatar file
    And I press "Save"
    Then I should see "Profile was successfully updated."
    And I sign out
Step definitions in Ruby
Test Results
Mechanize, Selenium / Webkit


•   Mechanize: fast, but no javascript support

•   Selenium, javascript support, but sloooow

•   Webkit, javascript support, less slooow
Ad

Recommended

Webinar: Schema Design
Webinar: Schema Design
MongoDB
 
MongoDB Schema Design
MongoDB Schema Design
Alex Litvinok
 
MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011
Steven Francia
 
NoSQL databases
NoSQL databases
Marc Seeger
 
Building Apps with MongoDB
Building Apps with MongoDB
Nate Abele
 
Dev Jumpstart: Schema Design Best Practices
Dev Jumpstart: Schema Design Best Practices
MongoDB
 
Practical Ruby Projects With Mongo Db
Practical Ruby Projects With Mongo Db
Alex Sharp
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling
DATAVERSITY
 
Schema design
Schema design
MongoDB
 
Learn Learn how to build your mobile back-end with MongoDB
Learn Learn how to build your mobile back-end with MongoDB
Marakana Inc.
 
Practical Ruby Projects (Alex Sharp)
Practical Ruby Projects (Alex Sharp)
MongoSF
 
Practical Ruby Projects with MongoDB - MongoSF
Practical Ruby Projects with MongoDB - MongoSF
Alex Sharp
 
CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009
Jason Davies
 
Advanced Document Modeling Techniques from a High-Scale Commerce Platform
Advanced Document Modeling Techniques from a High-Scale Commerce Platform
MongoDB
 
OSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB Tutorial
Steven Francia
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
MongoDB
 
Schema Design
Schema Design
MongoDB
 
MongoDB at ZPUGDC
MongoDB at ZPUGDC
Mike Dirolf
 
Graph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easily
Mark Needham
 
MongoDC 2012: How MongoDB Powers Doodle or Die
MongoDC 2012: How MongoDB Powers Doodle or Die
MongoDB
 
MongoDB and hadoop
MongoDB and hadoop
Steven Francia
 
GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A...
GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A...
Neo4j
 
Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DB
Mihail Mateev
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
MongoDB dessi-codemotion
MongoDB dessi-codemotion
Massimiliano Dessì
 
MongoDB and Ruby on Rails
MongoDB and Ruby on Rails
rfischer20
 
MongoDB
MongoDB
Steven Francia
 
Mongo or Die: How MongoDB Powers Doodle or Die
Mongo or Die: How MongoDB Powers Doodle or Die
Aaron Silverman
 
Identifying Antibiotics posing potential Health Risk: Microbial Resistance Sc...
Identifying Antibiotics posing potential Health Risk: Microbial Resistance Sc...
Atai Rabby
 
Tipos de biblioteca
Tipos de biblioteca
Vanesa Ovin
 

More Related Content

What's hot (20)

Schema design
Schema design
MongoDB
 
Learn Learn how to build your mobile back-end with MongoDB
Learn Learn how to build your mobile back-end with MongoDB
Marakana Inc.
 
Practical Ruby Projects (Alex Sharp)
Practical Ruby Projects (Alex Sharp)
MongoSF
 
Practical Ruby Projects with MongoDB - MongoSF
Practical Ruby Projects with MongoDB - MongoSF
Alex Sharp
 
CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009
Jason Davies
 
Advanced Document Modeling Techniques from a High-Scale Commerce Platform
Advanced Document Modeling Techniques from a High-Scale Commerce Platform
MongoDB
 
OSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB Tutorial
Steven Francia
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
MongoDB
 
Schema Design
Schema Design
MongoDB
 
MongoDB at ZPUGDC
MongoDB at ZPUGDC
Mike Dirolf
 
Graph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easily
Mark Needham
 
MongoDC 2012: How MongoDB Powers Doodle or Die
MongoDC 2012: How MongoDB Powers Doodle or Die
MongoDB
 
MongoDB and hadoop
MongoDB and hadoop
Steven Francia
 
GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A...
GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A...
Neo4j
 
Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DB
Mihail Mateev
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
MongoDB dessi-codemotion
MongoDB dessi-codemotion
Massimiliano Dessì
 
MongoDB and Ruby on Rails
MongoDB and Ruby on Rails
rfischer20
 
MongoDB
MongoDB
Steven Francia
 
Mongo or Die: How MongoDB Powers Doodle or Die
Mongo or Die: How MongoDB Powers Doodle or Die
Aaron Silverman
 
Schema design
Schema design
MongoDB
 
Learn Learn how to build your mobile back-end with MongoDB
Learn Learn how to build your mobile back-end with MongoDB
Marakana Inc.
 
Practical Ruby Projects (Alex Sharp)
Practical Ruby Projects (Alex Sharp)
MongoSF
 
Practical Ruby Projects with MongoDB - MongoSF
Practical Ruby Projects with MongoDB - MongoSF
Alex Sharp
 
CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009
Jason Davies
 
Advanced Document Modeling Techniques from a High-Scale Commerce Platform
Advanced Document Modeling Techniques from a High-Scale Commerce Platform
MongoDB
 
OSCON 2012 MongoDB Tutorial
OSCON 2012 MongoDB Tutorial
Steven Francia
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
MongoDB
 
Schema Design
Schema Design
MongoDB
 
MongoDB at ZPUGDC
MongoDB at ZPUGDC
Mike Dirolf
 
Graph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easily
Mark Needham
 
MongoDC 2012: How MongoDB Powers Doodle or Die
MongoDC 2012: How MongoDB Powers Doodle or Die
MongoDB
 
GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A...
GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A...
Neo4j
 
Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DB
Mihail Mateev
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
MongoDB and Ruby on Rails
MongoDB and Ruby on Rails
rfischer20
 
Mongo or Die: How MongoDB Powers Doodle or Die
Mongo or Die: How MongoDB Powers Doodle or Die
Aaron Silverman
 

Viewers also liked (20)

Identifying Antibiotics posing potential Health Risk: Microbial Resistance Sc...
Identifying Antibiotics posing potential Health Risk: Microbial Resistance Sc...
Atai Rabby
 
Tipos de biblioteca
Tipos de biblioteca
Vanesa Ovin
 
Rph Ringkas
Rph Ringkas
Rafidah Diah
 
Анимационный ролик мир вокруг нас
Анимационный ролик мир вокруг нас
Марина Д
 
Expectativas turismo-2016-informe
Expectativas turismo-2016-informe
Turistenístico
 
The new comers
The new comers
irongate55
 
Community health & wellness fest 2015
Community health & wellness fest 2015
Mary Phillips
 
кораблик
кораблик
Марина Д
 
Pdf slide show
Pdf slide show
yawarete
 
L
L
JW18260
 
Small Biz CEDC Orientation
Small Biz CEDC Orientation
Mary Phillips
 
Tweaking Open Source
Tweaking Open Source
Nelson Gomes
 
Cinco claves de los mercados hoteleros de Madrid y Barcelona 2016
Cinco claves de los mercados hoteleros de Madrid y Barcelona 2016
Turistenístico
 
Don't Write Them Off, Cast Iron Boilers Still Have a Future
Don't Write Them Off, Cast Iron Boilers Still Have a Future
BuildingMech
 
Gaya gerak listrik
Gaya gerak listrik
Andhryn Celica
 
台北國際烘焙暨設備展New
台北國際烘焙暨設備展New
EVERY8D 許
 
The Future of Travel in 2020
The Future of Travel in 2020
Turistenístico
 
Small biz expo & suit donation for the homeless
Small biz expo & suit donation for the homeless
Mary Phillips
 
Identifying Antibiotics posing potential Health Risk: Microbial Resistance Sc...
Identifying Antibiotics posing potential Health Risk: Microbial Resistance Sc...
Atai Rabby
 
Tipos de biblioteca
Tipos de biblioteca
Vanesa Ovin
 
Анимационный ролик мир вокруг нас
Анимационный ролик мир вокруг нас
Марина Д
 
Expectativas turismo-2016-informe
Expectativas turismo-2016-informe
Turistenístico
 
The new comers
The new comers
irongate55
 
Community health & wellness fest 2015
Community health & wellness fest 2015
Mary Phillips
 
Pdf slide show
Pdf slide show
yawarete
 
Small Biz CEDC Orientation
Small Biz CEDC Orientation
Mary Phillips
 
Tweaking Open Source
Tweaking Open Source
Nelson Gomes
 
Cinco claves de los mercados hoteleros de Madrid y Barcelona 2016
Cinco claves de los mercados hoteleros de Madrid y Barcelona 2016
Turistenístico
 
Don't Write Them Off, Cast Iron Boilers Still Have a Future
Don't Write Them Off, Cast Iron Boilers Still Have a Future
BuildingMech
 
台北國際烘焙暨設備展New
台北國際烘焙暨設備展New
EVERY8D 許
 
The Future of Travel in 2020
The Future of Travel in 2020
Turistenístico
 
Small biz expo & suit donation for the homeless
Small biz expo & suit donation for the homeless
Mary Phillips
 
Ad

Similar to Springest Dev Lunch: MongoDB Introduction (20)

Managing Social Content with MongoDB
Managing Social Content with MongoDB
MongoDB
 
Mongodb intro
Mongodb intro
christkv
 
MongoDB at GUL
MongoDB at GUL
Israel Gutiérrez
 
Mongo db presentation
Mongo db presentation
Julie Sommerville
 
Schema design
Schema design
christkv
 
Meetup#2: MongoDB Schema Design
Meetup#2: MongoDB Schema Design
Minsk MongoDB User Group
 
Schema Design by Example ~ MongoSF 2012
Schema Design by Example ~ MongoSF 2012
hungarianhc
 
2011 mongo sf-schemadesign
2011 mongo sf-schemadesign
MongoDB
 
Introduction to MongoDB
Introduction to MongoDB
Neil Henegan
 
mongoDB at Visibiz
mongoDB at Visibiz
Mike Brocious
 
Why NoSQL Makes Sense
Why NoSQL Makes Sense
MongoDB
 
Why NoSQL Makes Sense
Why NoSQL Makes Sense
MongoDB
 
SDEC2011 NoSQL Data modelling
SDEC2011 NoSQL Data modelling
Korea Sdec
 
Latinoware
Latinoware
kchodorow
 
Scaling with MongoDB
Scaling with MongoDB
MongoDB
 
SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and models
Korea Sdec
 
Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in Documents
MongoDB
 
SQL vs NoSQL
SQL vs NoSQL
Jacinto Limjap
 
MongoDB at RuPy
MongoDB at RuPy
Mike Dirolf
 
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
Matias Cascallares
 
Managing Social Content with MongoDB
Managing Social Content with MongoDB
MongoDB
 
Mongodb intro
Mongodb intro
christkv
 
Schema design
Schema design
christkv
 
Schema Design by Example ~ MongoSF 2012
Schema Design by Example ~ MongoSF 2012
hungarianhc
 
2011 mongo sf-schemadesign
2011 mongo sf-schemadesign
MongoDB
 
Introduction to MongoDB
Introduction to MongoDB
Neil Henegan
 
Why NoSQL Makes Sense
Why NoSQL Makes Sense
MongoDB
 
Why NoSQL Makes Sense
Why NoSQL Makes Sense
MongoDB
 
SDEC2011 NoSQL Data modelling
SDEC2011 NoSQL Data modelling
Korea Sdec
 
Scaling with MongoDB
Scaling with MongoDB
MongoDB
 
SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and models
Korea Sdec
 
Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in Documents
MongoDB
 
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
Matias Cascallares
 
Ad

Recently uploaded (20)

CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 

Springest Dev Lunch: MongoDB Introduction

  • 1. MongoDB (from “humongous”) Wouter de Vos – 2011-10-31
  • 2. What is MongoDB? • A No-SQL database • Document oriented • Open Source • Written in C++
  • 3. Document Oriented? • Documents are stored in collections > db.posts.findOne() { _id : ObjectId("4e77bb3b8a3e000000004f7a"), when : Date("2011-09-19T02:10:11.3Z", author : "alex", • title : "No Free Lunch", No JOINS: embedded text : "This is the text of the post. It could be very long.", tags : [ "business", "ramblings" ], votes : 5, voters : [ "jane", "joe", "spencer", "phyllis", "li" ], comments : [ • { who : "jane", when : Date("2011-09-19T04:00:10.112Z"), No JOINS: linked comment : "I agree." }, { who : "meghan", when : Date("2011-09-20T14:36:06.958Z"), comment : "You must be joking. etc etc ..." } ] }
  • 4. Document Oriented? • Documents are stored in collections > db.posts.findOne() { _id : ObjectId("4e77bb3b8a3e000000004f7a"), when : Date("2011-09-19T02:10:11.3Z", author : "alex", • title : "No Free Lunch", No JOINS: embedded text : "This is the text of the post. It could be very long.", tags : [ "business", "ramblings" ], votes : 5, voters : [ "jane", "joe", "spencer", "phyllis", "li" ], comments : [ • { who : "jane", when : Date("2011-09-19T04:00:10.112Z"), No JOINS: linked comment : "I agree." }, { who : "meghan", when : Date("2011-09-20T14:36:06.958Z"), comment : "You must be joking. etc etc ..." } ] }
  • 5. Document Oriented? • Documents are stored in collections > db.posts.findOne() • { No JOINS: embedded _id : ObjectId("4e77bb3b8a3e000000004f7a"), when : Date("2011-09-19T02:10:11.3Z", author : "alex", title : "No Free Lunch", text : "This is the text of the post. It could be very long.", • tags : [ "business", "ramblings" ], No JOINS: linked votes : 5, voters : [ "jane", "joe", "spencer", "phyllis", "li" ], comments : [ { who : "jane", when : Date("2011-09-19T04:00:10.112Z"), comment : "I agree." }, • { who : "meghan", when : Date("2011-09-20T14:36:06.958Z"), links are references to other documents and ] comment : "You must be joking. etc etc ..." } are processed by the client. }
  • 6. Cool features > db.invoices.find() { • Schemaless _id : ObjectId("4e77bb3b8a3e000000004f7a"), client: "Johnson", hosting: { per: "month", • price: 100, Atomic operations }, amount: 12, development: { per: "hour", • Map/Reduce } price: 120, amount: 80 }, • { Fast, in-place updates _id : ObjectId("4e77bb3b8a3e000000005f7a"), client: "Black", development: { per: "hour", • GridFS } price: 120, amount: 30 },
  • 7. Cool features • Schemaless atomically { if( doc.credits > 5 ) { doc.credits -= 5; • Atomic operations doc.debits += 5; } } • Map/Reduce • Fast, in-place updates • GridFS
  • 8. Cool features // Document example { username: "jones", likes: 20, text: "Hello world!" • Schemaless } // Map function() { • Atomic operations } emit( this.username, {count: 1, likes: this.likes} ); // Reduce • function(key, values) { Map/Reduce var result = {count: 0, likes: 0}; values.forEach(function(value) { result.count += value.count; • Fast, in-place updates result.likes += value.likes; }); return result; • } GridFS // Result { count: 10, likes: 247 }
  • 9. Cool features • Schemaless • Atomic operations // In place update db.recipes.update( • Map/Reduce ) {'_id': recipe_id, 'voters': {'$ne': user_id}}, {'$inc': {'votes': 1}, '$push': {'voters': user_id}} • Fast, in-place updates • GridFS
  • 10. Cool features • Schemaless • Atomic operations The GridFS spec provides a mechanism for transparently dividing a large file among multiple • Map/Reduce documents. This allows us to efficiently store large objects, and in the case of especially large files, such as videos, permits range operations (e.g., • Fast, in-place updates fetching only the first N bytes of a file). • GridFS
  • 11. Querying • // A post with title “Mongo” db.posts.find({'title': 'Mongo'}) • // All posts about tennis, but without comments db.posts.find( { tags : 'tennis' }, { comments : 0 } ); • // last 5 comments db.posts.find({}, {comments:{'$slice': -5}}) • // just the likes of the comments db.posts.find({}, {'comments.$.likes': 1}
  • 12. Use it for • It’s schemaless features (e.g. for prototyping) • It’s horizontal scalability (with auto-sharding) • To store and stream large files (with gridfs) • To make ultra-fast, single query updates
  • 14. Scenarios for browser testing Feature: User Registration and Logging in A User should be able to create an account. A User should be able to log in with a new account. A User should be able to create a profile after logging in for the first time. Scenario: Registration with a normal account. Given I sign up as a new user with [email protected]/secret Then I should be signed in And I sign out Scenario: Log in with a new account Given I sign up as a new user with [email protected]/secret Then I should be signed in Then I sign out And I sign in with [email protected]/secret Then I should be signed in And I sign out Scenario: Create a profile with a new account Given I sign in as a new user Then I should see "create your profile" And I fill in "profile_name" with "My Name" And I fill in "profile_about" with "I am a long green vegetable that goes well with salads." And I select an avatar file And I press "Save" Then I should see "Profile was successfully updated." And I sign out
  • 17. Mechanize, Selenium / Webkit • Mechanize: fast, but no javascript support • Selenium, javascript support, but sloooow • Webkit, javascript support, less slooow

Editor's Notes