SlideShare une entreprise Scribd logo
1  sur  18
An introduction to MongoDB
Rácz Gábor
ELTE IK, 2013. febr. 10.
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!

Contenu connexe

Tendances

MongoDb and NoSQL
MongoDb and NoSQLMongoDb and NoSQL
MongoDb and NoSQL
TO THE NEW | Technology
 
Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB
MongoDB
 
The Aggregation Framework
The Aggregation FrameworkThe Aggregation Framework
The Aggregation Framework
MongoDB
 

Tendances (20)

Beyond the Basics 2: Aggregation Framework
Beyond the Basics 2: Aggregation Framework Beyond the Basics 2: Aggregation Framework
Beyond the Basics 2: Aggregation Framework
 
MongoDb and NoSQL
MongoDb and NoSQLMongoDb and NoSQL
MongoDb and NoSQL
 
MongoDB
MongoDBMongoDB
MongoDB
 
Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for Beginners
 
Conexión de MongoDB con Hadoop - Luis Alberto Giménez - CAPSiDE #DevOSSAzureDays
Conexión de MongoDB con Hadoop - Luis Alberto Giménez - CAPSiDE #DevOSSAzureDaysConexión de MongoDB con Hadoop - Luis Alberto Giménez - CAPSiDE #DevOSSAzureDays
Conexión de MongoDB con Hadoop - Luis Alberto Giménez - CAPSiDE #DevOSSAzureDays
 
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial IndexesBack to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingApache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
 
NoSQL - An introduction to CouchDB
NoSQL - An introduction to CouchDBNoSQL - An introduction to CouchDB
NoSQL - An introduction to CouchDB
 
Webinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to BasicsWebinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to Basics
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and Python
 
Shankar's mongo db presentation
Shankar's mongo db presentationShankar's mongo db presentation
Shankar's mongo db presentation
 
Webinar: Working with Graph Data in MongoDB
Webinar: Working with Graph Data in MongoDBWebinar: Working with Graph Data in MongoDB
Webinar: Working with Graph Data in MongoDB
 
Conceptos básicos. Seminario web 5: Introducción a Aggregation Framework
Conceptos básicos. Seminario web 5: Introducción a Aggregation FrameworkConceptos básicos. Seminario web 5: Introducción a Aggregation Framework
Conceptos básicos. Seminario web 5: Introducción a Aggregation Framework
 
Back to Basics Webinar 3: Introduction to Replica Sets
Back to Basics Webinar 3: Introduction to Replica SetsBack to Basics Webinar 3: Introduction to Replica Sets
Back to Basics Webinar 3: Introduction to Replica Sets
 
PostgreSQL 9.4 JSON Types and Operators
PostgreSQL 9.4 JSON Types and OperatorsPostgreSQL 9.4 JSON Types and Operators
PostgreSQL 9.4 JSON Types and Operators
 
Webinar: Data Processing and Aggregation Options
Webinar: Data Processing and Aggregation OptionsWebinar: Data Processing and Aggregation Options
Webinar: Data Processing and Aggregation Options
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 
MongoDB and Python
MongoDB and PythonMongoDB and Python
MongoDB and Python
 
The Aggregation Framework
The Aggregation FrameworkThe Aggregation Framework
The Aggregation Framework
 

En vedette

6 1-ergonomie du web
6 1-ergonomie du web6 1-ergonomie du web
6 1-ergonomie du web
RYMAA
 
Infective Posterior Uveitides
Infective Posterior UveitidesInfective Posterior Uveitides
Infective Posterior Uveitides
Ripplewerkz
 
Calcium magnesium zinc benefits
Calcium magnesium zinc benefitsCalcium magnesium zinc benefits
Calcium magnesium zinc benefits
ionicmagnesium
 

En vedette (19)

Linked in
Linked inLinked in
Linked in
 
6 1-ergonomie du web
6 1-ergonomie du web6 1-ergonomie du web
6 1-ergonomie du web
 
Student Engagement Conference Keynote, Birmingham City University, June 2014
Student Engagement Conference Keynote, Birmingham City University, June 2014  Student Engagement Conference Keynote, Birmingham City University, June 2014
Student Engagement Conference Keynote, Birmingham City University, June 2014
 
What Works Intervention 2014
What Works Intervention 2014What Works Intervention 2014
What Works Intervention 2014
 
Level Up Student Transition, Raise Network Conference, Sept 2013
Level Up Student Transition, Raise Network Conference, Sept 2013Level Up Student Transition, Raise Network Conference, Sept 2013
Level Up Student Transition, Raise Network Conference, Sept 2013
 
Ch 1-la-révolution-des-tic-2010
Ch 1-la-révolution-des-tic-2010Ch 1-la-révolution-des-tic-2010
Ch 1-la-révolution-des-tic-2010
 
Alien rebooted gough bcu final
Alien rebooted gough bcu finalAlien rebooted gough bcu final
Alien rebooted gough bcu final
 
EFYE Student Academic Partners Jun 2014
EFYE Student Academic Partners Jun 2014EFYE Student Academic Partners Jun 2014
EFYE Student Academic Partners Jun 2014
 
current Affairs gk question for bank exam
current Affairs gk question for bank examcurrent Affairs gk question for bank exam
current Affairs gk question for bank exam
 
Infective Posterior Uveitides
Infective Posterior UveitidesInfective Posterior Uveitides
Infective Posterior Uveitides
 
BCU Meet Our Mentors EFYE Norway 2015
BCU Meet Our Mentors EFYE Norway 2015BCU Meet Our Mentors EFYE Norway 2015
BCU Meet Our Mentors EFYE Norway 2015
 
Linking in to Linked In? School of Education Employability Week Workshop
Linking in to Linked In? School of Education Employability Week WorkshopLinking in to Linked In? School of Education Employability Week Workshop
Linking in to Linked In? School of Education Employability Week Workshop
 
Calcium magnesium zinc benefits
Calcium magnesium zinc benefitsCalcium magnesium zinc benefits
Calcium magnesium zinc benefits
 
Concevoir un jeu-concours
Concevoir un jeu-concoursConcevoir un jeu-concours
Concevoir un jeu-concours
 
IBM Datapower
IBM DatapowerIBM Datapower
IBM Datapower
 
Commerce Électronique - Enjeux et tendances B2C
Commerce Électronique - Enjeux et tendances B2CCommerce Électronique - Enjeux et tendances B2C
Commerce Électronique - Enjeux et tendances B2C
 
British Science Festival: 40 Years of Star Wars
British Science Festival: 40 Years of Star WarsBritish Science Festival: 40 Years of Star Wars
British Science Festival: 40 Years of Star Wars
 
Vie jjp
Vie jjpVie jjp
Vie jjp
 
Toulouse lautrec
Toulouse lautrecToulouse lautrec
Toulouse lautrec
 

Similaire à Mongodb

mongoyeieheheieueheheueuehwwuwuuuwuwh.pptx
mongoyeieheheieueheheueuehwwuwuuuwuwh.pptxmongoyeieheheieueheheueuehwwuwuuuwuwh.pptx
mongoyeieheheieueheheueuehwwuwuuuwuwh.pptx
asiwalsanjib7
 
1403 app dev series - session 5 - analytics
1403   app dev series - session 5 - analytics1403   app dev series - session 5 - analytics
1403 app dev series - session 5 - analytics
MongoDB
 
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
 
First app online conf
First app   online confFirst app   online conf
First app online conf
MongoDB
 

Similaire à Mongodb (20)

lecture_40_1.ppt
lecture_40_1.pptlecture_40_1.ppt
lecture_40_1.ppt
 
lecture_40_1.pptx
lecture_40_1.pptxlecture_40_1.pptx
lecture_40_1.pptx
 
mongoyeieheheieueheheueuehwwuwuuuwuwh.pptx
mongoyeieheheieueheheueuehwwuwuuuwuwh.pptxmongoyeieheheieueheheueuehwwuwuuuwuwh.pptx
mongoyeieheheieueheheueuehwwuwuuuwuwh.pptx
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo
 
1403 app dev series - session 5 - analytics
1403   app dev series - session 5 - analytics1403   app dev series - session 5 - analytics
1403 app dev series - session 5 - analytics
 
Latinoware
LatinowareLatinoware
Latinoware
 
Building Your First MongoDB Application
Building Your First MongoDB ApplicationBuilding Your First MongoDB Application
Building Your First MongoDB Application
 
Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DBDealing with Azure Cosmos DB
Dealing with Azure Cosmos DB
 
Geoindexing with MongoDB
Geoindexing with MongoDBGeoindexing with MongoDB
Geoindexing with MongoDB
 
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
 
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
 
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
 
Full metal mongo
Full metal mongoFull metal mongo
Full metal mongo
 
MongoDB 3.0
MongoDB 3.0 MongoDB 3.0
MongoDB 3.0
 
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & AggregationWebinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
 
First app online conf
First app   online confFirst app   online conf
First app online conf
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
 

Dernier

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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Mongodb

  • 1. An introduction to MongoDB Rácz Gábor ELTE IK, 2013. febr. 10.
  • 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!

Notes de l'éditeur

  1. 2009: Initial release At now: version 2.2.3
  2. Huge quantity of data => Distributed systems => expensive joins => New fields, new demands (graphs) => Different data strucutres: Simplier or more specific
  3. Javascript
  4. Flexible schema Javascript
  5. 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 <document> 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
  6. http://docs.mongodb.org/manual/faq/storage/
  7. DC – Data center
  8. 1970 – 2000: Vertical Scalability (scale-up) Google, ~2000: Horizontal Scalability (scale-out)
  9. http://docs.mongodb.org/manual/reference/method/db.collection.mapReduce/#db.collection.mapReduce
  10. MongoDB A: What if a primary node is down?
  11. 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