SlideShare a Scribd company logo
An introduction to MongoDB
2
In Production
http://www.mongodb.org/about/production-deployments/
3
NoSQL
• Key-value
• Graph database
• Document-oriented
• Column family
4
Document store
RDBMS MongoDB
Database Database
Table, View Collection
Row Document (JSON, BSON)
Column Field
Index Index
Join Embedded Document
Foreign Key Reference
Partition Shard
5
Document store
RDBMS MongoDB
Database Database
Table, View Collection
Row Document (JSON, BSON)
Column Field
Index Index
Join Embedded Document
Foreign Key Reference
Partition Shard
> db.user.findOne({age:39})
{
"_id" : ObjectId("5114e0bd42…"),
"first" : "John",
"last" : "Doe",
"age" : 39,
"interests" : [
"Reading",
"Mountain Biking ]
"favorites": {
"color": "Blue",
"sport": "Soccer"}
}
6
CRUD
• Create
• db.collection.insert( <document> )
• db.collection.save( <document> )
• db.collection.update( <query>, <update>, { upsert: true } )
• Read
• db.collection.find( <query>, <projection> )
• db.collection.findOne( <query>, <projection> )
• Update
• db.collection.update( <query>, <update>, <options> )
• Delete
• db.collection.remove( <query>, <justOne> )
7
CRUD example
> db.user.insert({
first: "John",
last : "Doe",
age: 39
})
> db.user.find ()
{
"_id" : ObjectId("51…"),
"first" : "John",
"last" : "Doe",
"age" : 39
}
> db.user.update(
{"_id" : ObjectId("51…")},
{
$set: {
age: 40,
salary: 7000}
}
)
> db.user.remove({
"first": /^J/
})
8
Features
• Document-Oriented storege
• Full Index Support
• Replication & High
Availability
• Auto-Sharding
• Querying
• Fast In-Place Updates
• Map/Reduce
Agile
Scalable
9
Memory Mapped Files
• „A memory-mapped file is a segment of virtual memory which
has been assigned a direct byte-for-byte correlation with
some portion of a file or file-like resource.”1
• mmap()
1
: http://en.wikipedia.org/wiki/Memory-mapped_file
10
Replica Sets
• Redundancy and Failover
• Zero downtime for
upgrades and maintaince
• Master-slave replication
• Strong Consistency
• Delayed Consistency
• Geospatial features
Host1:10000
Host2:10001
Host3:10002
replica1
Client
11
Sharding
• Partition your data
• Scale write
throughput
• Increase capacity
• Auto-balancing
Host1:10000 Host2:10010
Host3:20000
shard1 shard2
Host4:30000
configdb
Client
12
Mixed
Host4:10010
Host5:20000
shard1
shardn
Host6:30000
configdb
Client
Host1:10000
Host2:10001
Host3:10002
replica1
Host7:30000
...
13
Map/Reduce
db.collection.mapReduce(
<mapfunction>,
<reducefunction>,
{
out: <collection>,
query: <>,
sort: <>,
limit: <number>,
finalize: <function>,
scope: <>,
jsMode: <boolean>,
verbose: <boolean>
}
)
var mapFunction1 = function() { emit(this.cust_id, this.price); };
var reduceFunction1 = function(keyCustId, valuesPrices)
{ return sum(valuesPrices); };
14
Other features
• Easy to install and use
• Detailed documentation
• Various APIs
• JavaScript, Python, Ruby, Perl, Java, Java, Scala, C#, C++, Haskell,
Erlang
• Community
• Open source
15
Theory of noSQL: CAP
CAP Theorem:
satisfying all three at the
same time is impossible
A P
• Many nodes
• Nodes contain replicas of
partitions of data
• Consistency
• all replicas contain the same
version of data
• Availability
• system remains operational on
failing nodes
• Partition tolarence
• multiple entry points
• system remains operational on
system split
C
16
Theory of noSQL: CAP
CAP Theorem:
satisfying all three at the
same time is impossible
A P
• Many nodes
• Nodes contain replicas of
partitions of data
• Consistency
• all replicas contain the same
version of data
• Availability
• system remains operational on
failing nodes
• Partition tolarence
• multiple entry points
• system remains operational on
system split
C
17
ACID - BASE
Pritchett, D.: BASE: An Acid Alternative (queue.acm.org/detail.cfm?id=1394128)
•Atomicity
•Consistency
•Isolation
•Durability
•Basically
Available (CP)
•Soft-state
•Eventually
consistent (AP)
18
Thank you for your attention!

More Related Content

What's hot (20)

PPTX
Back to Basics Webinar 1: Introduction to NoSQL
MongoDB
 
PDF
Data Processing and Aggregation with MongoDB
MongoDB
 
PPTX
Beyond the Basics 2: Aggregation Framework
MongoDB
 
PPTX
MongoDB for Beginners
Enoch Joshua
 
PDF
Using MongoDB and Python
Mike Bright
 
PPTX
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
MongoDB
 
PDF
MongoDB and Python
Norberto Leite
 
KEY
MongoDB
Steven Francia
 
PDF
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Myles Braithwaite
 
PDF
NoSQL - An introduction to CouchDB
Jonathan Weiss
 
PPTX
Shankar's mongo db presentation
Shankar Kamble
 
PDF
Webinar: Data Processing and Aggregation Options
MongoDB
 
PPTX
Conceptos básicos. Seminario web 5: Introducción a Aggregation Framework
MongoDB
 
PDF
MongoDB Aggregation Framework
Caserta
 
PPTX
PostgreSQL 9.4 JSON Types and Operators
Nicholas Kiraly
 
PPTX
Webinar: Getting Started with MongoDB - Back to Basics
MongoDB
 
PPTX
Back to Basics Webinar 3: Introduction to Replica Sets
MongoDB
 
PPTX
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
PDF
Mongo db
Noman Ellahi
 
PPTX
MongoDB - Aggregation Pipeline
Jason Terpko
 
Back to Basics Webinar 1: Introduction to NoSQL
MongoDB
 
Data Processing and Aggregation with MongoDB
MongoDB
 
Beyond the Basics 2: Aggregation Framework
MongoDB
 
MongoDB for Beginners
Enoch Joshua
 
Using MongoDB and Python
Mike Bright
 
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
MongoDB
 
MongoDB and Python
Norberto Leite
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Myles Braithwaite
 
NoSQL - An introduction to CouchDB
Jonathan Weiss
 
Shankar's mongo db presentation
Shankar Kamble
 
Webinar: Data Processing and Aggregation Options
MongoDB
 
Conceptos básicos. Seminario web 5: Introducción a Aggregation Framework
MongoDB
 
MongoDB Aggregation Framework
Caserta
 
PostgreSQL 9.4 JSON Types and Operators
Nicholas Kiraly
 
Webinar: Getting Started with MongoDB - Back to Basics
MongoDB
 
Back to Basics Webinar 3: Introduction to Replica Sets
MongoDB
 
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
Mongo db
Noman Ellahi
 
MongoDB - Aggregation Pipeline
Jason Terpko
 

Similar to Mongodb (20)

PPTX
mongoyeieheheieueheheueuehwwuwuuuwuwh.pptx
asiwalsanjib7
 
PPTX
lecture_40_1.pptx
RAGULNS1
 
PPT
lecture_40_1.ppt
BalramParmar5
 
PPT
MongoDB Basics Introduction along with MapReduce
anishachandaran1994
 
PPT
MongoDB a été développé par la société basée à New York 10gen en 2007, dans l...
marylinlamour
 
ODP
MongoDB - A Document NoSQL Database
Ruben Inoto Soto
 
PPTX
Introduction to MongoDB and Workshop
AhmedabadJavaMeetup
 
PDF
MongoDB.pdf
KuldeepKumar778733
 
PPT
9. Document Oriented Databases
Fabio Fumarola
 
PPTX
MongoDB_ppt.pptx
1AP18CS037ShirishKul
 
PPT
Building Your First MongoDB App ~ Metadata Catalog
hungarianhc
 
PPTX
MongoDB 3.0
Victoria Malaya
 
KEY
Mongodb intro
christkv
 
PDF
Introduction to MongoDB
Mike Dirolf
 
PDF
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
 
PPTX
introduction to Mongodb
ASIT
 
PDF
MongoDB for Coder Training (Coding Serbia 2013)
Uwe Printz
 
PPT
Introduction to MongoDB
Ravi Teja
 
PPTX
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
PDF
MongoDB FabLab León
Juan Antonio Roy Couto
 
mongoyeieheheieueheheueuehwwuwuuuwuwh.pptx
asiwalsanjib7
 
lecture_40_1.pptx
RAGULNS1
 
lecture_40_1.ppt
BalramParmar5
 
MongoDB Basics Introduction along with MapReduce
anishachandaran1994
 
MongoDB a été développé par la société basée à New York 10gen en 2007, dans l...
marylinlamour
 
MongoDB - A Document NoSQL Database
Ruben Inoto Soto
 
Introduction to MongoDB and Workshop
AhmedabadJavaMeetup
 
MongoDB.pdf
KuldeepKumar778733
 
9. Document Oriented Databases
Fabio Fumarola
 
MongoDB_ppt.pptx
1AP18CS037ShirishKul
 
Building Your First MongoDB App ~ Metadata Catalog
hungarianhc
 
MongoDB 3.0
Victoria Malaya
 
Mongodb intro
christkv
 
Introduction to MongoDB
Mike Dirolf
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
 
introduction to Mongodb
ASIT
 
MongoDB for Coder Training (Coding Serbia 2013)
Uwe Printz
 
Introduction to MongoDB
Ravi Teja
 
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
MongoDB FabLab León
Juan Antonio Roy Couto
 
Ad

More from Manav Prasad (20)

PPTX
Experience with mulesoft
Manav Prasad
 
PPTX
Mulesoftconnectors
Manav Prasad
 
PPT
Mule and web services
Manav Prasad
 
PPTX
Mulesoft cloudhub
Manav Prasad
 
PPT
Perl tutorial
Manav Prasad
 
PPT
Hibernate presentation
Manav Prasad
 
PPT
Jpa
Manav Prasad
 
PPT
Spring introduction
Manav Prasad
 
PPT
Json
Manav Prasad
 
PPT
The spring framework
Manav Prasad
 
PPT
Rest introduction
Manav Prasad
 
PPT
Exceptions in java
Manav Prasad
 
PPT
Junit
Manav Prasad
 
PPT
Xml parsers
Manav Prasad
 
PPT
Xpath
Manav Prasad
 
PPT
Xslt
Manav Prasad
 
PPT
Xhtml
Manav Prasad
 
PPT
Css
Manav Prasad
 
PPT
Introduction to html5
Manav Prasad
 
PPT
Ajax
Manav Prasad
 
Experience with mulesoft
Manav Prasad
 
Mulesoftconnectors
Manav Prasad
 
Mule and web services
Manav Prasad
 
Mulesoft cloudhub
Manav Prasad
 
Perl tutorial
Manav Prasad
 
Hibernate presentation
Manav Prasad
 
Spring introduction
Manav Prasad
 
The spring framework
Manav Prasad
 
Rest introduction
Manav Prasad
 
Exceptions in java
Manav Prasad
 
Xml parsers
Manav Prasad
 
Introduction to html5
Manav Prasad
 
Ad

Recently uploaded (20)

PPTX
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
PDF
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
PPTX
ENG8 Q1, WEEK 4.pptxoooiioooooooooooooooooooooooooo
chubbychubz1
 
PDF
Natural Language processing and web deigning notes
AnithaSakthivel3
 
PDF
Call For Papers - International Journal on Natural Language Computing (IJNLC)
kevig
 
PPTX
UNIT III CONTROL OF PARTICULATE CONTAMINANTS
sundharamm
 
PDF
An Evaluative Study on Performance Growth Plan of ICICI Mutual Fund and SBI M...
PoonamKilaniya
 
PDF
A NEW FAMILY OF OPTICALLY CONTROLLED LOGIC GATES USING NAPHTHOPYRAN MOLECULE
ijoejnl
 
PDF
13th International Conference of Networks and Communications (NC 2025)
JohannesPaulides
 
PPTX
File Strucutres and Access in Data Structures
mwaslam2303
 
PDF
NOISE CONTROL ppt - SHRESTH SUDHIR KOKNE
SHRESTHKOKNE
 
PPTX
Fluid statistics and Numerical on pascal law
Ravindra Kolhe
 
PDF
Web Technologies - Chapter 3 of Front end path.pdf
reemaaliasker
 
PDF
Non Text Magic Studio Magic Design for Presentations L&P.pdf
rajpal7872
 
PDF
MOBILE AND WEB BASED REMOTE BUSINESS MONITORING SYSTEM
ijait
 
PDF
BEE331-Week 04-SU25.pdf semiconductors UW
faemoxley
 
PDF
3.-Differential-Calculus-Part-2-NOTES.pdf
KurtMarbinCalicdan1
 
PDF
Comparative Analysis of the Use of Iron Ore Concentrate with Different Binder...
msejjournal
 
PDF
Natural Language processing and web deigning notes
AnithaSakthivel3
 
PDF
LEARNING CROSS-LINGUAL WORD EMBEDDINGS WITH UNIVERSAL CONCEPTS
kjim477n
 
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
ENG8 Q1, WEEK 4.pptxoooiioooooooooooooooooooooooooo
chubbychubz1
 
Natural Language processing and web deigning notes
AnithaSakthivel3
 
Call For Papers - International Journal on Natural Language Computing (IJNLC)
kevig
 
UNIT III CONTROL OF PARTICULATE CONTAMINANTS
sundharamm
 
An Evaluative Study on Performance Growth Plan of ICICI Mutual Fund and SBI M...
PoonamKilaniya
 
A NEW FAMILY OF OPTICALLY CONTROLLED LOGIC GATES USING NAPHTHOPYRAN MOLECULE
ijoejnl
 
13th International Conference of Networks and Communications (NC 2025)
JohannesPaulides
 
File Strucutres and Access in Data Structures
mwaslam2303
 
NOISE CONTROL ppt - SHRESTH SUDHIR KOKNE
SHRESTHKOKNE
 
Fluid statistics and Numerical on pascal law
Ravindra Kolhe
 
Web Technologies - Chapter 3 of Front end path.pdf
reemaaliasker
 
Non Text Magic Studio Magic Design for Presentations L&P.pdf
rajpal7872
 
MOBILE AND WEB BASED REMOTE BUSINESS MONITORING SYSTEM
ijait
 
BEE331-Week 04-SU25.pdf semiconductors UW
faemoxley
 
3.-Differential-Calculus-Part-2-NOTES.pdf
KurtMarbinCalicdan1
 
Comparative Analysis of the Use of Iron Ore Concentrate with Different Binder...
msejjournal
 
Natural Language processing and web deigning notes
AnithaSakthivel3
 
LEARNING CROSS-LINGUAL WORD EMBEDDINGS WITH UNIVERSAL CONCEPTS
kjim477n
 

Mongodb

  • 3. 3 NoSQL • Key-value • Graph database • Document-oriented • Column family
  • 4. 4 Document store RDBMS MongoDB Database Database Table, View Collection Row Document (JSON, BSON) Column Field Index Index Join Embedded Document Foreign Key Reference Partition Shard
  • 5. 5 Document store RDBMS MongoDB Database Database Table, View Collection Row Document (JSON, BSON) Column Field Index Index Join Embedded Document Foreign Key Reference Partition Shard > db.user.findOne({age:39}) { "_id" : ObjectId("5114e0bd42…"), "first" : "John", "last" : "Doe", "age" : 39, "interests" : [ "Reading", "Mountain Biking ] "favorites": { "color": "Blue", "sport": "Soccer"} }
  • 6. 6 CRUD • Create • db.collection.insert( <document> ) • db.collection.save( <document> ) • db.collection.update( <query>, <update>, { upsert: true } ) • Read • db.collection.find( <query>, <projection> ) • db.collection.findOne( <query>, <projection> ) • Update • db.collection.update( <query>, <update>, <options> ) • Delete • db.collection.remove( <query>, <justOne> )
  • 7. 7 CRUD example > db.user.insert({ first: "John", last : "Doe", age: 39 }) > db.user.find () { "_id" : ObjectId("51…"), "first" : "John", "last" : "Doe", "age" : 39 } > db.user.update( {"_id" : ObjectId("51…")}, { $set: { age: 40, salary: 7000} } ) > db.user.remove({ "first": /^J/ })
  • 8. 8 Features • Document-Oriented storege • Full Index Support • Replication & High Availability • Auto-Sharding • Querying • Fast In-Place Updates • Map/Reduce Agile Scalable
  • 9. 9 Memory Mapped Files • „A memory-mapped file is a segment of virtual memory which has been assigned a direct byte-for-byte correlation with some portion of a file or file-like resource.”1 • mmap() 1 : http://en.wikipedia.org/wiki/Memory-mapped_file
  • 10. 10 Replica Sets • Redundancy and Failover • Zero downtime for upgrades and maintaince • Master-slave replication • Strong Consistency • Delayed Consistency • Geospatial features Host1:10000 Host2:10001 Host3:10002 replica1 Client
  • 11. 11 Sharding • Partition your data • Scale write throughput • Increase capacity • Auto-balancing Host1:10000 Host2:10010 Host3:20000 shard1 shard2 Host4:30000 configdb Client
  • 13. 13 Map/Reduce db.collection.mapReduce( <mapfunction>, <reducefunction>, { out: <collection>, query: <>, sort: <>, limit: <number>, finalize: <function>, scope: <>, jsMode: <boolean>, verbose: <boolean> } ) var mapFunction1 = function() { emit(this.cust_id, this.price); }; var reduceFunction1 = function(keyCustId, valuesPrices) { return sum(valuesPrices); };
  • 14. 14 Other features • Easy to install and use • Detailed documentation • Various APIs • JavaScript, Python, Ruby, Perl, Java, Java, Scala, C#, C++, Haskell, Erlang • Community • Open source
  • 15. 15 Theory of noSQL: CAP CAP Theorem: satisfying all three at the same time is impossible A P • Many nodes • Nodes contain replicas of partitions of data • Consistency • all replicas contain the same version of data • Availability • system remains operational on failing nodes • Partition tolarence • multiple entry points • system remains operational on system split C
  • 16. 16 Theory of noSQL: CAP CAP Theorem: satisfying all three at the same time is impossible A P • Many nodes • Nodes contain replicas of partitions of data • Consistency • all replicas contain the same version of data • Availability • system remains operational on failing nodes • Partition tolarence • multiple entry points • system remains operational on system split C
  • 17. 17 ACID - BASE Pritchett, D.: BASE: An Acid Alternative (queue.acm.org/detail.cfm?id=1394128) •Atomicity •Consistency •Isolation •Durability •Basically Available (CP) •Soft-state •Eventually consistent (AP)
  • 18. 18 Thank you for your attention!

Editor's Notes

  • #3: 2009: Initial release At now: version 2.2.3
  • #4: Huge quantity of data =&amp;gt; Distributed systems =&amp;gt; expensive joins =&amp;gt; New fields, new demands (graphs) =&amp;gt; Different data strucutres: Simplier or more specific
  • #5: Javascript
  • #6: Flexible schema Javascript
  • #7: Create The field name _id is reserved for use as a primary key; its value must be unique in the collection, is immutable, and may be of any type other than an array. The field names cannot start with the $ character. The field names cannot contain the . character. Create with save If the &amp;lt;document&amp;gt; argument does not contain the _id field or contains an _id field with a value not in the collection, the save() method performs an insert of the document. Otherwise, the save() method performs an update. sds
  • #10: http://docs.mongodb.org/manual/faq/storage/
  • #11: DC – Data center
  • #12: 1970 – 2000: Vertical Scalability (scale-up) Google, ~2000: Horizontal Scalability (scale-out)
  • #14: http://docs.mongodb.org/manual/reference/method/db.collection.mapReduce/#db.collection.mapReduce
  • #17: MongoDB A: What if a primary node is down?
  • #18: ACID Atomicity. All of the operations in the transaction will complete, or none will. Consistency. The database will be in a consistent state when the transaction begins and ends. Isolation. The transaction will behave as if it is the only operation being performed upon the database. Durability. Upon completion of the transaction, the operation will not be reversed. BASE Basically Available: some parts of system remain availabe on failure Soft-state: (the information will expire unless it is refreshed ) system will change state without user intervention due to eventual consistency Eventually consistency: asynchron propagation consistancy window