SlideShare a Scribd company logo
1 of 31
Download to read offline
Massimiliano Dessì
in 25 min
Speaker
Software architect/developer Pronetics/Sourcesense
Founder Spring Italian User Group
Chairman JugSardegna Onlus
Committer/Contributor OpenNMS - MongoDB
Author Spring 2.5 Aspect Oriented Programming
Target
Deployments
http://www.mongodb.org/display/DOCS/Production+Deployments
Features
•  Document-oriented
–  Documents (objects) map nicely to programming language data types
–  Embedded documents and arrays reduce need for joins
–  Dynamically-typed (schemaless) for easy schema evolution
–  No joins and no transactions for high performance and easy scalability
•  High performance
–  No joins and no transactions makes reads and writes fast
–  Indexes with indexing into embedded documents and arrays
–  Optional asynchronous writes
•  High availability
–  Replicated servers with automatic master failover
•  Easy scalability
–  "slaveOK" reads are distributed over replicated servers
–  Automatic sharding (auto-partitioning of data across servers)
–  Reads and writes are distributed over shards
–  No joins and no transactions make distributed queries easy and fast
•  Rich query language
{"greeting" : ”Hello world !”}
JSONize your data
http://www.mongodb.org
{ "name" : "MongoDB",
"info" : { "storage" : "Binary JSON (BSON)",
"full index" : "true",
"scale" : "Autosharding",
"query" : "Rich document-base queries",
"replication" : "Replica sets",
"atomic modifiers" : "Fast in place update",
"binary content" : "GridFS",
"batch operation" : "Map/Reduce”
”js server side" : ”true”
},
"_id” : "024x6f279578a64bb0686743"
}
No Join
Data container
Document instead of Row
Collections and subcollections
instead of Tables
Document limit
Larger than 4MB
The entire text of War and Peace is
3.14 MB...
Driver
C, C#, C++, Clojure, D, Delphi, Erlang,
Factor, Fantom, F#, Go, Groovy,
Haskell, Java, Javascript, Lua, Nodejs,
ObjectiveC, Perl, PHP, Python, R,
Ruby, Scala, Scheme (PLT), Smalltalk
http://www.mongodb.org/display/DOCS/Drivers
No constraints
Collections are schema free
Documents within a single collection
can have any
number of different
"shapes”
No SQL Injection
Mongo is invulnerable to injection
attacks, no code execution
Insert
db.mycollection.insert({"name" : "foo"})
Delete
db.mycollection.delete({"name" : "foo"})
Update
The schema can be changed (schema
free)
var item = db.mycollection.findOne({"name" : "foo"});
item.albums = {"2009" : "greatest hits”};
item.members = {”number" : ”5"};
db.mycollection.update({”name” : ”foo"}, item);
Upsert
Update or insert if not present
db.mycollection.update({”name” : ”sam"}, true);
Fastest
Fire and Forget
Command with response
getLastError
Mongo Shell
Modifiers
Partial updates
$set (set a key, or add if not present)
$inc (with numbers)
$push (add to the end of an array)
$ne
$addToSet
$each
$pop (remove from the end)
$pull (remove element that match criteria)
Query
Return all keys in the document
db.mycollection.find({"name" : "foo"})
Keys to return (second param)
db.mycollection.find({}, {”name" : 1})
Query criteria
Conditionals
$lt $lte $gt $gte
start = new Date("01/01/2010")
db.mycollection.find({"registered" : {"$lt" :
start}})
db.mycollection.find({”name" : {"$ne" : ”foo"}})
Query criteria
Conditionals
$in $or, $nin, $not
<, <=, >, >=, $ne, $mod, $all, $size, $exists
db.mycollection.find({”external_num" : {"$nin" :
[1356, 525, 874]}})
db.mycollection.find({"$or" : [{"ticket_no" :
525}, {”name" : foo}]})
Query REGEX
Perl Compatible Regular Expression
db.mycollection.find({"name" : /foo?/i})
Query on Array
Inside a document
$all $size $slice
Grouping
count distinct group finalize $key
Where Query
JavaScript as part of your query
db.mycollection.find({"$where" : function () {
for (var current in this) {
}
…}
Indexing
db.mycollection.ensureIndex({"name" : 1,
"info" : 1 }
Geospatial indexing
db.mycollection.ensureIndex({"gps" : "2d"})
db.star.trek.ensureIndex(
{"light-years" : "2d"}, {"min”:-10, "max”:10})
Map Reduce
map = function() {
for (var key in this) {
emit(key, {count : 1});
}
};
reduce = function(key, emits) {
total = 0;
for (var i in emits) {
total += emits[i].count;
}
return {"count" : total};
}
Replication
Replica set, clustering with automatic
failover
Master is elected by the cluster and
may change to another node if the
current master goes down
Sharding
Splitting data and storing different
portions of the data on different
machines, also know as partitioning
Option: auto/manual
GridFS
GridFS is a specification for storing large
files such video, photos, blob in MongoDB
.
GridFS uses two collections to store data:
• files contains the object metadata
• chunks contains the binary chunks with
some additional accounting information
Books
http://www.mongodb.org/display/DOCS/Books
Thanks !
Massimiliano Dessì
desmax74 at yahoo.it
http://twitter.com/desmax74
http://jroller.com/desmax
http://www.linkedin.com/in/desmax74
http://wiki.java.net/bin/view/People/MassimilianoDessi
http://www.jugsardegna.org/vqwiki/jsp/Wiki?MassimilianoDessi

More Related Content

What's hot

Morphia: Simplifying Persistence for Java and MongoDB
Morphia:  Simplifying Persistence for Java and MongoDBMorphia:  Simplifying Persistence for Java and MongoDB
Morphia: Simplifying Persistence for Java and MongoDB
Jeff Yemin
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph database
Artem Orobets
 
Java Development with MongoDB
Java Development with MongoDBJava Development with MongoDB
Java Development with MongoDB
Scott Hernandez
 
Introduction to couch_db
Introduction to couch_dbIntroduction to couch_db
Introduction to couch_db
Romain Testard
 
Building Spring Data with MongoDB
Building Spring Data with MongoDBBuilding Spring Data with MongoDB
Building Spring Data with MongoDB
MongoDB
 

What's hot (19)

Morphia: Simplifying Persistence for Java and MongoDB
Morphia:  Simplifying Persistence for Java and MongoDBMorphia:  Simplifying Persistence for Java and MongoDB
Morphia: Simplifying Persistence for Java and MongoDB
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDB
 
Webinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaWebinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and Java
 
Java development with MongoDB
Java development with MongoDBJava development with MongoDB
Java development with MongoDB
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph database
 
Java Development with MongoDB
Java Development with MongoDBJava Development with MongoDB
Java Development with MongoDB
 
Introduction to couch_db
Introduction to couch_dbIntroduction to couch_db
Introduction to couch_db
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with Morphia
 
MongoDB and hadoop
MongoDB and hadoopMongoDB and hadoop
MongoDB and hadoop
 
2012 phoenix mug
2012 phoenix mug2012 phoenix mug
2012 phoenix mug
 
Webinar: Transitioning from SQL to MongoDB
Webinar: Transitioning from SQL to MongoDBWebinar: Transitioning from SQL to MongoDB
Webinar: Transitioning from SQL to MongoDB
 
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 
DrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and DrupalDrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and Drupal
 
Building Spring Data with MongoDB
Building Spring Data with MongoDBBuilding Spring Data with MongoDB
Building Spring Data with MongoDB
 
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
 
Introduction to Restkit
Introduction to RestkitIntroduction to Restkit
Introduction to Restkit
 
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...
 
Practical Ruby Projects With Mongo Db
Practical Ruby Projects With Mongo DbPractical Ruby Projects With Mongo Db
Practical Ruby Projects With Mongo Db
 

Viewers also liked (6)

Web Marketing Training 2014 Community Online
Web Marketing Training 2014 Community OnlineWeb Marketing Training 2014 Community Online
Web Marketing Training 2014 Community Online
 
Spring Roo JaxItalia09
Spring Roo JaxItalia09Spring Roo JaxItalia09
Spring Roo JaxItalia09
 
Javaday Roma2007 Magic Box Kiss With Spring
Javaday Roma2007 Magic Box Kiss With SpringJavaday Roma2007 Magic Box Kiss With Spring
Javaday Roma2007 Magic Box Kiss With Spring
 
Spring Stack Testing:Continuous integration,Continuous Agitation
Spring Stack Testing:Continuous integration,Continuous AgitationSpring Stack Testing:Continuous integration,Continuous Agitation
Spring Stack Testing:Continuous integration,Continuous Agitation
 
Scala linux day 2012
Scala linux day 2012 Scala linux day 2012
Scala linux day 2012
 
Scala Italy 2013 extended Scalatra vs Spring MVC
Scala Italy 2013 extended Scalatra vs Spring MVCScala Italy 2013 extended Scalatra vs Spring MVC
Scala Italy 2013 extended Scalatra vs Spring MVC
 

Similar to MongoDB Webtech conference 2010

MongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB Shell Tips & Tricks
MongoDB Shell Tips & Tricks
MongoDB
 
Shell Tips and Tricks
Shell Tips and TricksShell Tips and Tricks
Shell Tips and Tricks
MongoDB
 
Workshop presentation hands on r programming
Workshop presentation hands on r programmingWorkshop presentation hands on r programming
Workshop presentation hands on r programming
Nimrita Koul
 
Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Db
chriskite
 

Similar to MongoDB Webtech conference 2010 (20)

MongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB Shell Tips & Tricks
MongoDB Shell Tips & Tricks
 
Shell Tips and Tricks
Shell Tips and TricksShell Tips and Tricks
Shell Tips and Tricks
 
Software Language Design & Engineering
Software Language Design & EngineeringSoftware Language Design & Engineering
Software Language Design & Engineering
 
Modern, Scalable, Ambitious apps with Ember.js
Modern, Scalable, Ambitious apps with Ember.jsModern, Scalable, Ambitious apps with Ember.js
Modern, Scalable, Ambitious apps with Ember.js
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
Software Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & SpoofaxSoftware Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & Spoofax
 
MongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
MongoDB at the Silicon Valley iPhone and iPad Developers' MeetupMongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
MongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
 
MongoDB dessi-codemotion
MongoDB dessi-codemotionMongoDB dessi-codemotion
MongoDB dessi-codemotion
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196
 
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, PuppetPuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
 
Script of Scripts Polyglot Notebook and Workflow System
Script of ScriptsPolyglot Notebook and Workflow SystemScript of ScriptsPolyglot Notebook and Workflow System
Script of Scripts Polyglot Notebook and Workflow System
 
Workshop presentation hands on r programming
Workshop presentation hands on r programmingWorkshop presentation hands on r programming
Workshop presentation hands on r programming
 
London HUG 12/4
London HUG 12/4London HUG 12/4
London HUG 12/4
 
Play á la Rails
Play á la RailsPlay á la Rails
Play á la Rails
 
Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Db
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Evil
 
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
 

More from Massimiliano Dessì

More from Massimiliano Dessì (20)

Code One 2018 maven
Code One 2018   mavenCode One 2018   maven
Code One 2018 maven
 
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
 
Hacking Maven Linux day 2017
Hacking Maven Linux day 2017Hacking Maven Linux day 2017
Hacking Maven Linux day 2017
 
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloud
 
Docker dDessi november 2015
Docker dDessi november 2015Docker dDessi november 2015
Docker dDessi november 2015
 
Docker linuxday 2015
Docker linuxday 2015Docker linuxday 2015
Docker linuxday 2015
 
Openshift linuxday 2014
Openshift linuxday 2014Openshift linuxday 2014
Openshift linuxday 2014
 
Vert.X like Node.js but polyglot and reactive on JVM
Vert.X like Node.js but polyglot and reactive on JVMVert.X like Node.js but polyglot and reactive on JVM
Vert.X like Node.js but polyglot and reactive on JVM
 
Reactive applications Linux Day 2013
Reactive applications Linux Day 2013Reactive applications Linux Day 2013
Reactive applications Linux Day 2013
 
Codemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_sprayCodemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_spray
 
Why we cannot ignore functional programming
Why we cannot ignore functional programmingWhy we cannot ignore functional programming
Why we cannot ignore functional programming
 
Three languages in thirty minutes
Three languages in thirty minutesThree languages in thirty minutes
Three languages in thirty minutes
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
Spring Roo Internals Javaday IV
Spring Roo Internals Javaday IVSpring Roo Internals Javaday IV
Spring Roo Internals Javaday IV
 
Spring3.0 JaxItalia09
Spring3.0 JaxItalia09Spring3.0 JaxItalia09
Spring3.0 JaxItalia09
 
MongoDB Scala Roma SpringFramework Meeting2009
MongoDB Scala Roma SpringFramework Meeting2009MongoDB Scala Roma SpringFramework Meeting2009
MongoDB Scala Roma SpringFramework Meeting2009
 
Scala Programming Linux Day 2009
Scala Programming Linux Day 2009Scala Programming Linux Day 2009
Scala Programming Linux Day 2009
 
MongoDB SpringFramework Meeting september 2009
MongoDB SpringFramework Meeting september 2009MongoDB SpringFramework Meeting september 2009
MongoDB SpringFramework Meeting september 2009
 
The hidden gems of Spring Security
The hidden gems of Spring SecurityThe hidden gems of Spring Security
The hidden gems of Spring Security
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
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...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

MongoDB Webtech conference 2010

  • 2. Speaker Software architect/developer Pronetics/Sourcesense Founder Spring Italian User Group Chairman JugSardegna Onlus Committer/Contributor OpenNMS - MongoDB Author Spring 2.5 Aspect Oriented Programming
  • 5. Features •  Document-oriented –  Documents (objects) map nicely to programming language data types –  Embedded documents and arrays reduce need for joins –  Dynamically-typed (schemaless) for easy schema evolution –  No joins and no transactions for high performance and easy scalability •  High performance –  No joins and no transactions makes reads and writes fast –  Indexes with indexing into embedded documents and arrays –  Optional asynchronous writes •  High availability –  Replicated servers with automatic master failover •  Easy scalability –  "slaveOK" reads are distributed over replicated servers –  Automatic sharding (auto-partitioning of data across servers) –  Reads and writes are distributed over shards –  No joins and no transactions make distributed queries easy and fast •  Rich query language
  • 6. {"greeting" : ”Hello world !”} JSONize your data http://www.mongodb.org
  • 7. { "name" : "MongoDB", "info" : { "storage" : "Binary JSON (BSON)", "full index" : "true", "scale" : "Autosharding", "query" : "Rich document-base queries", "replication" : "Replica sets", "atomic modifiers" : "Fast in place update", "binary content" : "GridFS", "batch operation" : "Map/Reduce” ”js server side" : ”true” }, "_id” : "024x6f279578a64bb0686743" } No Join
  • 8. Data container Document instead of Row Collections and subcollections instead of Tables
  • 9. Document limit Larger than 4MB The entire text of War and Peace is 3.14 MB...
  • 10. Driver C, C#, C++, Clojure, D, Delphi, Erlang, Factor, Fantom, F#, Go, Groovy, Haskell, Java, Javascript, Lua, Nodejs, ObjectiveC, Perl, PHP, Python, R, Ruby, Scala, Scheme (PLT), Smalltalk http://www.mongodb.org/display/DOCS/Drivers
  • 11. No constraints Collections are schema free Documents within a single collection can have any number of different "shapes”
  • 12. No SQL Injection Mongo is invulnerable to injection attacks, no code execution
  • 14. Update The schema can be changed (schema free) var item = db.mycollection.findOne({"name" : "foo"}); item.albums = {"2009" : "greatest hits”}; item.members = {”number" : ”5"}; db.mycollection.update({”name” : ”foo"}, item);
  • 15. Upsert Update or insert if not present db.mycollection.update({”name” : ”sam"}, true);
  • 16. Fastest Fire and Forget Command with response getLastError
  • 18. Modifiers Partial updates $set (set a key, or add if not present) $inc (with numbers) $push (add to the end of an array) $ne $addToSet $each $pop (remove from the end) $pull (remove element that match criteria)
  • 19. Query Return all keys in the document db.mycollection.find({"name" : "foo"}) Keys to return (second param) db.mycollection.find({}, {”name" : 1})
  • 20. Query criteria Conditionals $lt $lte $gt $gte start = new Date("01/01/2010") db.mycollection.find({"registered" : {"$lt" : start}}) db.mycollection.find({”name" : {"$ne" : ”foo"}})
  • 21. Query criteria Conditionals $in $or, $nin, $not <, <=, >, >=, $ne, $mod, $all, $size, $exists db.mycollection.find({”external_num" : {"$nin" : [1356, 525, 874]}}) db.mycollection.find({"$or" : [{"ticket_no" : 525}, {”name" : foo}]})
  • 22. Query REGEX Perl Compatible Regular Expression db.mycollection.find({"name" : /foo?/i})
  • 23. Query on Array Inside a document $all $size $slice Grouping count distinct group finalize $key
  • 24. Where Query JavaScript as part of your query db.mycollection.find({"$where" : function () { for (var current in this) { } …}
  • 25. Indexing db.mycollection.ensureIndex({"name" : 1, "info" : 1 } Geospatial indexing db.mycollection.ensureIndex({"gps" : "2d"}) db.star.trek.ensureIndex( {"light-years" : "2d"}, {"min”:-10, "max”:10})
  • 26. Map Reduce map = function() { for (var key in this) { emit(key, {count : 1}); } }; reduce = function(key, emits) { total = 0; for (var i in emits) { total += emits[i].count; } return {"count" : total}; }
  • 27. Replication Replica set, clustering with automatic failover Master is elected by the cluster and may change to another node if the current master goes down
  • 28. Sharding Splitting data and storing different portions of the data on different machines, also know as partitioning Option: auto/manual
  • 29. GridFS GridFS is a specification for storing large files such video, photos, blob in MongoDB . GridFS uses two collections to store data: • files contains the object metadata • chunks contains the binary chunks with some additional accounting information
  • 31. Thanks ! Massimiliano Dessì desmax74 at yahoo.it http://twitter.com/desmax74 http://jroller.com/desmax http://www.linkedin.com/in/desmax74 http://wiki.java.net/bin/view/People/MassimilianoDessi http://www.jugsardegna.org/vqwiki/jsp/Wiki?MassimilianoDessi