SlideShare a Scribd company logo
Introduction to MongoDB
Matthew Bates
Solution Architect
MongoDB EMEA
2
MongoDB
The leading NoSQL database
Document
Database
Open-
Source
General
Purpose
3
Relational Database Challenges
Data Types
•  Unstructured data
•  Semi-structured
data
•  Polymorphic data
Volume of Data
•  Petabytes of data
•  Trillions of records
•  Millions of queries per
second
Agile Development
•  Iterative
•  Short development
cycles
•  New workloads
New Architectures
•  Horizontal scaling
•  Commodity servers
•  Cloud computing
4
Document Data Model
Relational - Tables
{ first_name: ‘Paul’,!
surname: ‘Miller’,!
city: ‘London’,!
location: {!
!type: “Point”,
!coordinates :!
! ![-0.128, 51.507]!
!},!
cars: [ !
{ model: ‘Bentley’,!
year: 1973,!
value: 100000, … },!
{ model: ‘Rolls Royce’,!
year: 1965,!
value: 330000, … }!
}!
}!
Document - Collections
5
Dynamic Schema Documents
name: “jeff”,
eyes: “blue”,
height: 72,
boss: “ben”}
{name: “brendan”,
aliases: [“el diablo”]}
name: “ben”,
hat: ”yes”}
{name: “matt”,
pizza: “DiGiorno”,
height: 72,
boss: 555.555.1212}
{name: “will”,
eyes: “blue”,
birthplace: “NY”,
aliases: [“bill”, “la
ciacco”],
gender: ”???”,
boss: ”ben”}
6
Document Model
•  Agility and flexibility – dynamic schema
–  Data models can evolve easily
–  Companies can adapt to changes quickly
•  Intuitive, natural data representation
–  Remove impedance mismatch
–  Many types of applications are a good fit
•  Reduces the need for joins, disk seeks
–  Programming is more simple
–  Performance can be delivered at scale
7
Simplify Development
8
Simplify Development
9
Rich Database Interaction
10
MongoDB: An Operational Database
11
Shell
Command-line shell for
interacting directly with
database
Shell and Drivers
Drivers
Drivers for most popular
programming languages and
frameworks
> db.collection.insert({company:“10gen”,
product:“MongoDB”})
>
> db.collection.findOne()
{
“_id” : ObjectId(“5106c1c2fc629bfe52792e86”),
“company” : “10gen”
“product” : “MongoDB”
}
Java
Python
Perl
Ruby
Haskell
JavaScript
12
•  Ad-hoc queries
•  Real-time aggregation
•  Rich query capabilities
•  Index support - secondary, compound, text, geo
and more
•  Strong (traditional) consistency
•  Geospatial features
•  Support for most programming languages
•  Flexible schema
MongoDB is Full Featured
13
Features In Practice
Queries
•  Find Paul’s cars
•  Find everybody in London with a car
built between 1970 and 1980
Geospatial
•  Find all of the car owners within 5km of
Trafalgar Sq.
Text Search
•  Find all the cars described as having
leather seats
Aggregation
•  Calculate the average value of Paul’s
car collection
Map Reduce
•  What is the ownership pattern of colors
by geography over time? (is purple
trending up in China?)
{ first_name: ‘Paul’,!
surname: ‘Miller’,!
city: ‘London’,!
location: {!
!type: “Point”,
!coordinates :!
! ![-0.128, 51.507]!
!},!
cars: [ !
{ model: ‘Bentley’,!
year: 1973,!
value: 100000, … },!
{ model: ‘Rolls Royce’,!
year: 1965,!
value: 330000, … }!
}!
}!
14
Query Example
Rich Queries
•  Find Paul’s cars
•  Find everybody in London with a car
built between 1970 and 1980
db.cars.find({
first_name: ‘Paul’!
})
db.cars.find({
!city: ‘London’,
”cars.year" : {
$gte : 1970,
$lte : 1980
}
})
!
{ first_name: ‘Paul’,!
surname: ‘Miller’,!
city: ‘London’,!
location: {!
!type: “Point”,
!coordinates :!
! ![-0.128, 51.507]!
!},!
cars: [ !
{ model: ‘Bentley’,!
year: 1973,!
value: 100000, … },!
{ model: ‘Rolls Royce’,!
year: 1965,!
value: 330000, … }!
}!
}!
15
Geo Spatial Example
db.cars.find( {
location:
{ $near :
{ $geometry :
{ type: 'Point' ,
coordinates :
[-0.128,51.507]
}
},
$maxDistance :5000
}
} )
!
Geospatial
•  Find all of the car owners within 5km of
Trafalgar Sq.
{ first_name: ‘Paul’,!
surname: ‘Miller’,!
city: ‘London’,!
location: {!
!type: “Point”,
!coordinates :!
! ![-0.128, 51.507]!
!},!
cars: [ !
{ model: ‘Bentley’,!
year: 1973,!
value: 100000, … },!
{ model: ‘Rolls Royce’,!
year: 1965,!
value: 330000, … }!
}!
}!
16
Aggregation Framework Example
db.cars.aggregate( [
{$match : {"first_name" : "Paul"}},
{$project : {"first_name":1,"cars":1}},
{$unwind : "$cars"},
{ $group : {_id:"$first_name",
average : {
$avg : "$cars.value"}}}
])
{ "_id" : "Paul", "average" : 215000 }
!
Aggregation
•  Calculate the average value of Paul’s
car collection
{ first_name: ‘Paul’,!
surname: ‘Miller’,!
city: ‘London’,!
location: {!
!type: “Point”,
!coordinates :!
! ![-0.128, 51.507]!
!},!
cars: [ !
{ model: ‘Bentley’,!
year: 1973,!
value: 100000, … },!
{ model: ‘Rolls Royce’,!
year: 1965,!
value: 330000, … }!
}!
}!
Scalability
18
Automatic Sharding
•  Three types of sharding: hash-based, range-based, tag-
aware
•  Increase or decrease capacity as you go
•  Automatic balancing
19
Query Routing
•  Multiple query optimization models
•  Each sharding option appropriate for different apps
Availability
21
Replica Sets
•  Replica Set – two or more copies
•  “Self-healing” shard
•  Addresses many concerns:
-  High Availability
-  Disaster Recovery
-  Maintenance
22
Replica Set Benefits
Business Needs Replica Set Benefits
High Availability Automated failover
Disaster Recovery Hot backups offsite
Maintenance Rolling upgrades
Low Latency Locate data near users
Workload Isolation Read from non-primary replicas
Data Privacy Restrict data to physical location
Data Consistency Tunable Consistency
Performance
24
Better Data
Locality
Performance
In-Memory
Caching
In-Place
Updates
25
Disk Seeks and Data Locality
Seek = 5+ ms Read = really really fast
User
Comment
Article
26
Disk Seeks and Data Locality
Article
User
CommentCommentCommentCommentComment
Use Cases
28
MongoDB Use Cases
Big Data Product & Asset
Catalogs
Security &
Fraud
Internet of
Things
Database-as-a-
Service
Mobile
Apps
Customer Data
Management
Data
Hub
Social &
Collaboration
Content
Management
Intelligence Agencies
Top Investment and
Retail Banks
Top US Retailer
Top Global Shipping
Company
Top Industrial Equipment
Manufacturer
Top Media Company
Top Investment and
Retail Banks
29
•  Document Model
–  Simplify development
–  Simplify scale out
–  Improve performance
•  MongoDB – leading NoSQL database
–  Rich general purpose database
–  Fully featured
–  Built-in HA (High Availability) and automated failover
–  Built-in horizontal scale-out
Summary
30
Getting Started
http://www.mongodb.org/downloads
31
Online Documentation
http://docs.mongodb.org
32
MongoDB University
http://university.mongodb.com
33
For More Information
Resource Location
MongoDB Downloads mongodb.com/download
Free Online Training education.mongodb.com
Webinars and Events mongodb.com/events
White Papers mongodb.com/white-papers
Case Studies mongodb.com/customers
Presentations mongodb.com/presentations
Documentation docs.mongodb.org
Additional Info info@mongodb.com
Resource Location
An Introduction to Mongo DB

More Related Content

PDF
Intrapreneurs july2015
PDF
Inaugural Addresses
PDF
Teaching Students with Emojis, Emoticons, & Textspeak
PDF
Hype vs. Reality: The AI Explainer
PDF
Study: The Future of VR, AR and Self-Driving Cars
PPTX
Webinar: Getting Started with MongoDB - Back to Basics
PPTX
Webinar : Premiers pas avec MongoDB - Back to Basics
PPTX
S01 e00 einfuehrung-in_mongodb
Intrapreneurs july2015
Inaugural Addresses
Teaching Students with Emojis, Emoticons, & Textspeak
Hype vs. Reality: The AI Explainer
Study: The Future of VR, AR and Self-Driving Cars
Webinar: Getting Started with MongoDB - Back to Basics
Webinar : Premiers pas avec MongoDB - Back to Basics
S01 e00 einfuehrung-in_mongodb

Similar to An Introduction to Mongo DB (20)

PDF
Neotys conference
PPTX
The Right (and Wrong) Use Cases for MongoDB
PDF
MongoDB Workshop Sophia Conf 2018
PPTX
tranSMART Community Meeting 5-7 Nov 13 - Session 2: MongoDB: What, Why And When
PPTX
Webinar: General Technical Overview of MongoDB for Ops Teams
PPTX
MongoDB Evenings DC: MongoDB - The New Default Database for Giant Ideas
PDF
Jumpstart! Building Your First MongoDB App Using Atlas & Stitch
PPTX
Building your First MEAN App
PPTX
Jumpstart! From SQL to NoSQL -- Changing Your Mindset
PDF
MongoDB: Back to Basics
PPTX
MongoDB Schema Design
PPTX
Introduction to NoSQL
PPTX
Intro to MongoDB (Extended Session)
PDF
MongoDB .local Houston 2019: Jumpstart: From SQL to NoSQL -- Changing Your Mi...
PPTX
Intro to MongoDB Workshop
PDF
MongoDB .local Chicago 2019: From SQL to NoSQL -- Changing Your Mindset
PPTX
OrientDB - cloud barcamp Libero Cloud
PPTX
Python Ireland Conference 2016 - Python and MongoDB Workshop
PPTX
The openCypher Project - An Open Graph Query Language
PPTX
Retail referencearchitecture productcatalog
Neotys conference
The Right (and Wrong) Use Cases for MongoDB
MongoDB Workshop Sophia Conf 2018
tranSMART Community Meeting 5-7 Nov 13 - Session 2: MongoDB: What, Why And When
Webinar: General Technical Overview of MongoDB for Ops Teams
MongoDB Evenings DC: MongoDB - The New Default Database for Giant Ideas
Jumpstart! Building Your First MongoDB App Using Atlas & Stitch
Building your First MEAN App
Jumpstart! From SQL to NoSQL -- Changing Your Mindset
MongoDB: Back to Basics
MongoDB Schema Design
Introduction to NoSQL
Intro to MongoDB (Extended Session)
MongoDB .local Houston 2019: Jumpstart: From SQL to NoSQL -- Changing Your Mi...
Intro to MongoDB Workshop
MongoDB .local Chicago 2019: From SQL to NoSQL -- Changing Your Mindset
OrientDB - cloud barcamp Libero Cloud
Python Ireland Conference 2016 - Python and MongoDB Workshop
The openCypher Project - An Open Graph Query Language
Retail referencearchitecture productcatalog
Ad

Recently uploaded (20)

PPTX
Cloud computing and distributed systems.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
Teaching material agriculture food technology
PDF
Electronic commerce courselecture one. Pdf
PDF
KodekX | Application Modernization Development
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Spectroscopy.pptx food analysis technology
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Cloud computing and distributed systems.
Dropbox Q2 2025 Financial Results & Investor Presentation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
MYSQL Presentation for SQL database connectivity
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Teaching material agriculture food technology
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation_ Review paper, used for researhc scholars
Spectroscopy.pptx food analysis technology
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Review of recent advances in non-invasive hemoglobin estimation
The AUB Centre for AI in Media Proposal.docx
Building Integrated photovoltaic BIPV_UPV.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Ad

An Introduction to Mongo DB

  • 1. Introduction to MongoDB Matthew Bates Solution Architect MongoDB EMEA
  • 2. 2 MongoDB The leading NoSQL database Document Database Open- Source General Purpose
  • 3. 3 Relational Database Challenges Data Types •  Unstructured data •  Semi-structured data •  Polymorphic data Volume of Data •  Petabytes of data •  Trillions of records •  Millions of queries per second Agile Development •  Iterative •  Short development cycles •  New workloads New Architectures •  Horizontal scaling •  Commodity servers •  Cloud computing
  • 4. 4 Document Data Model Relational - Tables { first_name: ‘Paul’,! surname: ‘Miller’,! city: ‘London’,! location: {! !type: “Point”, !coordinates :! ! ![-0.128, 51.507]! !},! cars: [ ! { model: ‘Bentley’,! year: 1973,! value: 100000, … },! { model: ‘Rolls Royce’,! year: 1965,! value: 330000, … }! }! }! Document - Collections
  • 5. 5 Dynamic Schema Documents name: “jeff”, eyes: “blue”, height: 72, boss: “ben”} {name: “brendan”, aliases: [“el diablo”]} name: “ben”, hat: ”yes”} {name: “matt”, pizza: “DiGiorno”, height: 72, boss: 555.555.1212} {name: “will”, eyes: “blue”, birthplace: “NY”, aliases: [“bill”, “la ciacco”], gender: ”???”, boss: ”ben”}
  • 6. 6 Document Model •  Agility and flexibility – dynamic schema –  Data models can evolve easily –  Companies can adapt to changes quickly •  Intuitive, natural data representation –  Remove impedance mismatch –  Many types of applications are a good fit •  Reduces the need for joins, disk seeks –  Programming is more simple –  Performance can be delivered at scale
  • 11. 11 Shell Command-line shell for interacting directly with database Shell and Drivers Drivers Drivers for most popular programming languages and frameworks > db.collection.insert({company:“10gen”, product:“MongoDB”}) > > db.collection.findOne() { “_id” : ObjectId(“5106c1c2fc629bfe52792e86”), “company” : “10gen” “product” : “MongoDB” } Java Python Perl Ruby Haskell JavaScript
  • 12. 12 •  Ad-hoc queries •  Real-time aggregation •  Rich query capabilities •  Index support - secondary, compound, text, geo and more •  Strong (traditional) consistency •  Geospatial features •  Support for most programming languages •  Flexible schema MongoDB is Full Featured
  • 13. 13 Features In Practice Queries •  Find Paul’s cars •  Find everybody in London with a car built between 1970 and 1980 Geospatial •  Find all of the car owners within 5km of Trafalgar Sq. Text Search •  Find all the cars described as having leather seats Aggregation •  Calculate the average value of Paul’s car collection Map Reduce •  What is the ownership pattern of colors by geography over time? (is purple trending up in China?) { first_name: ‘Paul’,! surname: ‘Miller’,! city: ‘London’,! location: {! !type: “Point”, !coordinates :! ! ![-0.128, 51.507]! !},! cars: [ ! { model: ‘Bentley’,! year: 1973,! value: 100000, … },! { model: ‘Rolls Royce’,! year: 1965,! value: 330000, … }! }! }!
  • 14. 14 Query Example Rich Queries •  Find Paul’s cars •  Find everybody in London with a car built between 1970 and 1980 db.cars.find({ first_name: ‘Paul’! }) db.cars.find({ !city: ‘London’, ”cars.year" : { $gte : 1970, $lte : 1980 } }) ! { first_name: ‘Paul’,! surname: ‘Miller’,! city: ‘London’,! location: {! !type: “Point”, !coordinates :! ! ![-0.128, 51.507]! !},! cars: [ ! { model: ‘Bentley’,! year: 1973,! value: 100000, … },! { model: ‘Rolls Royce’,! year: 1965,! value: 330000, … }! }! }!
  • 15. 15 Geo Spatial Example db.cars.find( { location: { $near : { $geometry : { type: 'Point' , coordinates : [-0.128,51.507] } }, $maxDistance :5000 } } ) ! Geospatial •  Find all of the car owners within 5km of Trafalgar Sq. { first_name: ‘Paul’,! surname: ‘Miller’,! city: ‘London’,! location: {! !type: “Point”, !coordinates :! ! ![-0.128, 51.507]! !},! cars: [ ! { model: ‘Bentley’,! year: 1973,! value: 100000, … },! { model: ‘Rolls Royce’,! year: 1965,! value: 330000, … }! }! }!
  • 16. 16 Aggregation Framework Example db.cars.aggregate( [ {$match : {"first_name" : "Paul"}}, {$project : {"first_name":1,"cars":1}}, {$unwind : "$cars"}, { $group : {_id:"$first_name", average : { $avg : "$cars.value"}}} ]) { "_id" : "Paul", "average" : 215000 } ! Aggregation •  Calculate the average value of Paul’s car collection { first_name: ‘Paul’,! surname: ‘Miller’,! city: ‘London’,! location: {! !type: “Point”, !coordinates :! ! ![-0.128, 51.507]! !},! cars: [ ! { model: ‘Bentley’,! year: 1973,! value: 100000, … },! { model: ‘Rolls Royce’,! year: 1965,! value: 330000, … }! }! }!
  • 18. 18 Automatic Sharding •  Three types of sharding: hash-based, range-based, tag- aware •  Increase or decrease capacity as you go •  Automatic balancing
  • 19. 19 Query Routing •  Multiple query optimization models •  Each sharding option appropriate for different apps
  • 21. 21 Replica Sets •  Replica Set – two or more copies •  “Self-healing” shard •  Addresses many concerns: -  High Availability -  Disaster Recovery -  Maintenance
  • 22. 22 Replica Set Benefits Business Needs Replica Set Benefits High Availability Automated failover Disaster Recovery Hot backups offsite Maintenance Rolling upgrades Low Latency Locate data near users Workload Isolation Read from non-primary replicas Data Privacy Restrict data to physical location Data Consistency Tunable Consistency
  • 25. 25 Disk Seeks and Data Locality Seek = 5+ ms Read = really really fast User Comment Article
  • 26. 26 Disk Seeks and Data Locality Article User CommentCommentCommentCommentComment
  • 28. 28 MongoDB Use Cases Big Data Product & Asset Catalogs Security & Fraud Internet of Things Database-as-a- Service Mobile Apps Customer Data Management Data Hub Social & Collaboration Content Management Intelligence Agencies Top Investment and Retail Banks Top US Retailer Top Global Shipping Company Top Industrial Equipment Manufacturer Top Media Company Top Investment and Retail Banks
  • 29. 29 •  Document Model –  Simplify development –  Simplify scale out –  Improve performance •  MongoDB – leading NoSQL database –  Rich general purpose database –  Fully featured –  Built-in HA (High Availability) and automated failover –  Built-in horizontal scale-out Summary
  • 33. 33 For More Information Resource Location MongoDB Downloads mongodb.com/download Free Online Training education.mongodb.com Webinars and Events mongodb.com/events White Papers mongodb.com/white-papers Case Studies mongodb.com/customers Presentations mongodb.com/presentations Documentation docs.mongodb.org Additional Info info@mongodb.com Resource Location