SlideShare a Scribd company logo
1 of 14
Download to read offline
MongoDB

 Part I
What is "NoSQL"?

Complement, not replace, traditional relational databases
Different ways to store large quantities of denormalized
data
   Key/Value = Redis, Riak
   Tabular / "Big Table" = HBase, Cassandra
   Document = MongoDB, CouchDB
No schema
Map/Reduce
Easy scalability
RDMS is just fine

YES!
When you must guarantee transactional/ACID behavior
When you must have strict constraints
But...not when these are more important
   Faster queries
   Horizontal scalability
   Flexible design
Data Modeling with SQL
Joins? We ain't got no stinking joins
Data Modeling with MongoDB
 Beware the N+1 problem does lurk

      Having no method for joining
      means we could have a lot of
      queries on our hands if we do
      establish a large one-to-many
      relationship outside of our
      "User" document
MongoDB, BSON, and You

MongoDB does "document" storage
JSON is a popular lightweight data structure
BSON is a binary encoded serialized JSON document
Programming languages map to-from BSON easily
   Most languages have a dictionary or hash
What does it look like?
{ "_id" : ObjectId("4d240d296266ea4ff500000a"),
"first_name" : "Nick", "last_name" : "Zalabak",  
"addresses" : [ 
    {"street" : "123 Foo Bar Ave","city": "Chicago","state":
"IL"},
    {"street": "1 Mongo Blvd", "city": "Blah", "state": "CA"} ],
"social_networks" : [
     {"user_id": "user1", "sn": "twitter"}, 
     {"user_id": "user2", "sn": "facebook"}
],
"phone_numbers" : [ "123-345-1345", "555-555-5785"] }
How do I install MongoDB?

Go to http://www.mongodb.org/downloads
For Macs I'd recommend using Brew
   brew install mongodb
For Linux, it depends on your distro
   Pre-Packaged for Ubuntu/Debian
   Pre-Packaged for CentOS/Fedora/Redhat
   Good old source!
There are even installers for WinDoze
The './mongo' Console

MongoDB has a console very much like MySQL
  >./mongo
  > help
OK, how do I query to find my stuff?
The new query language you already know

                MongoDB
                <3
               JSON
              <3
          JavaScript
SQL to Mongo Operations
SQL Statement                                    Mongo Query Language Statement



CREATE TABLE USERS (a Number, b Number) implicit. MongoDB is "lazy".
INSERT INTO USERS VALUES(1,1)           db.users.insert({a:1,b:1})db.users.find({}, {a:1,b:1})
SELECT a,b FROM users



SELECT a,b FROM users WHERE                      db.users.find({age:33}, {a:1,b:1})db.users.find({'age':
age=33SELECT * FROM users WHERE                  {$gt:33}})})db.users.find({name:/Joe/})
age>33SELECT * FROM users WHERE name
LIKE "%Joe%"

EXPLAIN SELECT * FROM users WHERE z=3SELECT      db.users.find({z:3}).explain()db.users.distinct('last_name') db.
DISTINCT last_name FROM users UPDATE users SET   users.update({b:'q'}, {$set:{a:1}}, false, true)
a=1 WHERE b='q'




DELETE FROM users WHERE z="abc"                  db.users.remove({z:'abc'});
The Compelling Sales Pitch

More Related Content

What's hot

Knockout vs. angular
Knockout vs. angularKnockout vs. angular
Knockout vs. angular
MaslowB
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentation
Murat Çakal
 
"Powerful Analysis with the Aggregation Pipeline (Tutorial)"
"Powerful Analysis with the Aggregation Pipeline (Tutorial)""Powerful Analysis with the Aggregation Pipeline (Tutorial)"
"Powerful Analysis with the Aggregation Pipeline (Tutorial)"
MongoDB
 

What's hot (19)

MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
Starting out with MongoDB
Starting out with MongoDBStarting out with MongoDB
Starting out with MongoDB
 
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
 
Building Your First MongoDB App ~ Metadata Catalog
Building Your First MongoDB App ~ Metadata CatalogBuilding Your First MongoDB App ~ Metadata Catalog
Building Your First MongoDB App ~ Metadata Catalog
 
Mysql to mongo
Mysql to mongoMysql to mongo
Mysql to mongo
 
Schema Design by Example ~ MongoSF 2012
Schema Design by Example ~ MongoSF 2012Schema Design by Example ~ MongoSF 2012
Schema Design by Example ~ MongoSF 2012
 
Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patterns
 
Knockout vs. angular
Knockout vs. angularKnockout vs. angular
Knockout vs. angular
 
MongoDB & Drupal
MongoDB & DrupalMongoDB & Drupal
MongoDB & Drupal
 
Simple MongoDB design for Rails apps
Simple MongoDB design for Rails appsSimple MongoDB design for Rails apps
Simple MongoDB design for Rails apps
 
Leichtgewichtige Webwenwendungen mit dem MEAN-Stack
Leichtgewichtige Webwenwendungen mit dem MEAN-StackLeichtgewichtige Webwenwendungen mit dem MEAN-Stack
Leichtgewichtige Webwenwendungen mit dem MEAN-Stack
 
Angela Distratis, Luca Pelosi - How to earn a black belt in GraphQL testing ...
Angela Distratis, Luca Pelosi - How to earn a black belt in GraphQL testing ...Angela Distratis, Luca Pelosi - How to earn a black belt in GraphQL testing ...
Angela Distratis, Luca Pelosi - How to earn a black belt in GraphQL testing ...
 
MongoDB for Analytics
MongoDB for AnalyticsMongoDB for Analytics
MongoDB for Analytics
 
06. ElasticSearch : Mapping and Analysis
06. ElasticSearch : Mapping and Analysis06. ElasticSearch : Mapping and Analysis
06. ElasticSearch : Mapping and Analysis
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentation
 
Building a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and JavaBuilding a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and Java
 
Geospatial Indexing and Querying with MongoDB
Geospatial Indexing and Querying with MongoDBGeospatial Indexing and Querying with MongoDB
Geospatial Indexing and Querying with MongoDB
 
"Powerful Analysis with the Aggregation Pipeline (Tutorial)"
"Powerful Analysis with the Aggregation Pipeline (Tutorial)""Powerful Analysis with the Aggregation Pipeline (Tutorial)"
"Powerful Analysis with the Aggregation Pipeline (Tutorial)"
 
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right WayMongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
 

Similar to MongoDB

Eagle6 mongo dc revised
Eagle6 mongo dc revisedEagle6 mongo dc revised
Eagle6 mongo dc revised
MongoDB
 
introtomongodb
introtomongodbintrotomongodb
introtomongodb
saikiran
 
Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Db
chriskite
 

Similar to MongoDB (20)

MongoDB
MongoDBMongoDB
MongoDB
 
Mongo Web Apps: OSCON 2011
Mongo Web Apps: OSCON 2011Mongo Web Apps: OSCON 2011
Mongo Web Apps: OSCON 2011
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
MongoDB.local DC 2018: Tutorial - Data Analytics with MongoDB
MongoDB.local DC 2018: Tutorial - Data Analytics with MongoDBMongoDB.local DC 2018: Tutorial - Data Analytics with MongoDB
MongoDB.local DC 2018: Tutorial - Data Analytics with MongoDB
 
MongoDB a document store that won't let you down.
MongoDB a document store that won't let you down.MongoDB a document store that won't let you down.
MongoDB a document store that won't let you down.
 
MongoDB .local London 2019: Managing Diverse User Needs with MongoDB and SQL
MongoDB .local London 2019: Managing Diverse User Needs with MongoDB and SQLMongoDB .local London 2019: Managing Diverse User Needs with MongoDB and SQL
MongoDB .local London 2019: Managing Diverse User Needs with MongoDB and SQL
 
Data Analytics with MongoDB - Jane Fine
Data Analytics with MongoDB - Jane FineData Analytics with MongoDB - Jane Fine
Data Analytics with MongoDB - Jane Fine
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
 
MongoDB Knowledge share
MongoDB Knowledge shareMongoDB Knowledge share
MongoDB Knowledge share
 
Online | MongoDB Atlas on GCP Workshop
Online | MongoDB Atlas on GCP Workshop Online | MongoDB Atlas on GCP Workshop
Online | MongoDB Atlas on GCP Workshop
 
Introduction to MongoDB and Workshop
Introduction to MongoDB and WorkshopIntroduction to MongoDB and Workshop
Introduction to MongoDB and Workshop
 
MongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and ImplicationsMongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and Implications
 
Talk MongoDB - Amil
Talk MongoDB - AmilTalk MongoDB - Amil
Talk MongoDB - Amil
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
 
Eagle6 mongo dc revised
Eagle6 mongo dc revisedEagle6 mongo dc revised
Eagle6 mongo dc revised
 
Eagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational AwarenessEagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational Awareness
 
MongoDB Meetup
MongoDB MeetupMongoDB Meetup
MongoDB Meetup
 
Database Wizardry for Legacy Applications
Database Wizardry for Legacy ApplicationsDatabase Wizardry for Legacy Applications
Database Wizardry for Legacy Applications
 
introtomongodb
introtomongodbintrotomongodb
introtomongodb
 
Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Db
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
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
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

MongoDB

  • 2. What is "NoSQL"? Complement, not replace, traditional relational databases Different ways to store large quantities of denormalized data Key/Value = Redis, Riak Tabular / "Big Table" = HBase, Cassandra Document = MongoDB, CouchDB No schema Map/Reduce Easy scalability
  • 3. RDMS is just fine YES! When you must guarantee transactional/ACID behavior When you must have strict constraints But...not when these are more important Faster queries Horizontal scalability Flexible design
  • 5. Joins? We ain't got no stinking joins
  • 7.  Beware the N+1 problem does lurk Having no method for joining means we could have a lot of queries on our hands if we do establish a large one-to-many relationship outside of our "User" document
  • 8. MongoDB, BSON, and You MongoDB does "document" storage JSON is a popular lightweight data structure BSON is a binary encoded serialized JSON document Programming languages map to-from BSON easily Most languages have a dictionary or hash
  • 9. What does it look like? { "_id" : ObjectId("4d240d296266ea4ff500000a"), "first_name" : "Nick", "last_name" : "Zalabak",   "addresses" : [      {"street" : "123 Foo Bar Ave","city": "Chicago","state": "IL"},     {"street": "1 Mongo Blvd", "city": "Blah", "state": "CA"} ], "social_networks" : [      {"user_id": "user1", "sn": "twitter"},       {"user_id": "user2", "sn": "facebook"} ], "phone_numbers" : [ "123-345-1345", "555-555-5785"] }
  • 10. How do I install MongoDB? Go to http://www.mongodb.org/downloads For Macs I'd recommend using Brew brew install mongodb For Linux, it depends on your distro Pre-Packaged for Ubuntu/Debian Pre-Packaged for CentOS/Fedora/Redhat Good old source! There are even installers for WinDoze
  • 11. The './mongo' Console MongoDB has a console very much like MySQL >./mongo > help OK, how do I query to find my stuff?
  • 12. The new query language you already know  MongoDB <3 JSON <3 JavaScript
  • 13. SQL to Mongo Operations SQL Statement Mongo Query Language Statement CREATE TABLE USERS (a Number, b Number) implicit. MongoDB is "lazy". INSERT INTO USERS VALUES(1,1) db.users.insert({a:1,b:1})db.users.find({}, {a:1,b:1}) SELECT a,b FROM users SELECT a,b FROM users WHERE db.users.find({age:33}, {a:1,b:1})db.users.find({'age': age=33SELECT * FROM users WHERE {$gt:33}})})db.users.find({name:/Joe/}) age>33SELECT * FROM users WHERE name LIKE "%Joe%" EXPLAIN SELECT * FROM users WHERE z=3SELECT db.users.find({z:3}).explain()db.users.distinct('last_name') db. DISTINCT last_name FROM users UPDATE users SET users.update({b:'q'}, {$set:{a:1}}, false, true) a=1 WHERE b='q' DELETE FROM users WHERE z="abc" db.users.remove({z:'abc'});