SlideShare a Scribd company logo
1 of 39
Download to read offline
Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Speaker

Software architect/developer Pronetics/Sourcesense
        Founder Spring Italian User Group
            Chairman JugSardegna
  Committer/Contributor OpenNMS - MongoDB
 Author Spring 2.5 Aspect Oriented Programming



                                       Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
MongoDB Philosophy




                     Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Some MongoDB production deployments




               http://www.mongodb.org/display/DOCS/Production+Deployments
                                        Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Main Features
●   Document Oriented
                                                                          ●   Easy scalability

    - Documents (objects) map nicely to programming language data types       - "slaveOK" reads are distributed over replicated servers

    - Dynamically-typed (schemaless) for easy schema evolution                - Automatic sharding (auto-partitioning of data across servers)

    - No joins and no transactions for high performance                       - Reads and writes are distributed over shards

     and easy scalability                                                     - No joins and no transactions make distributed queries easy and fast

●   High Performance
                                                                          ●   High Availability

    - No joins and no transactions makes reads and writes fast                - Replicated servers with automatic master failover

    - Indexes with indexing into embedded documents and arrays
                                                                          ●   Indexing

    - Optional asynchronous writes
                                                                          ●   Stored JavaScript

●   Rich Query Language
                                                                          ●   Fixed-size collection
                                                                          ●   File storage
                                                                          ●   MapReduce
                                                                                                      Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
No Sql Injection


Mongo is invulnerable to injection attacks, no code execution




                                               Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Document as Basic unit of Data in BSON (Binary JSON) format
{ "name" : "MongoDB",

  "info" : { "storage" : "Binary JSON (BSON)",

              "full index" : "true",                         Document: an Ordered set of keys with associated values
              "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”

  }

  "greeting": {"international" : "Hello, world!", "italy" :"Ciao Mondo !" }

}, "_id” : "024x6f279578a64bb0666945"


                                                                       Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Grouping

                                                        SQL
                                          Table contains Rows




                                                     MONGO
                Collection and subcollections contains Documents


* Document Limit: Larger than 4 Mb, the entire text of War and Peace is 3.14Mb

              Collection are are created dynamically and automatically grow in size to fit additional data




                                                                                         Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
A single instance of MongoDB can host
multiple independent databases, each of
  which can have its own collections
           and permissions.



                                                               Photo from http://www.aibento.net/



                                          Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
No Join's cost

●   SQL
             SELECT * FROM posts
             INNER JOIN posts_tags ON posts.id = posts_tags.post_id
             INNER JOIN tags ON posts_tags.tag_id == tags.id
             WHERE tags.text = 'politics' AND posts.vote_count > 10;



●   MONGO
            db.posts.find({'tags': 'politics', 'vote_count': {'$gt': 10}});




                                                   Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Collections Schema free

Documents within a single collection can have any number of different "shapes”

In theory, each document in a collection
can have a completely different structure;
in practice, a collection's documents
will be relatively uniform.



                                                       Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
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


                                         Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Common operations
                Fastest : Fire and Forget
             Command with response : getLastError


                      Examples with


            Server side Javascript via mongo shell
           Java via MongoDB Official 10gen Driver
Scala via Casbah Official 10gen scala driver + Salat serializer
                                               Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Inserting

//mongo shell

db.dcComicsCollection.insert({"name" : "bruce", "surname" : "wayne", "alias" : "batman"})



//Java

Map fields = batman.toMap()

dcComicsCollection.insert(BasicDBObjectBuilder.start(fields).get())         //java driver



//scala

dcComicsCollection.insert(grater[BlogPost].asDBObject(post))




                                                               Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Removing

//mongo shell

db.dcComicsCollection.delete({"alias" : "superman"})



//java

Map query = batman.getMap()

DBObject obj = BasicDBObjectBuilder.start(fields).get()

dcComicsColl.remove(obj);



//scala

dcComicsCollection.remove(grater[BlogPost].asDBObject(post)




                                                              Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Updating (The schema can be changed dinamically)
//mongo shell

var hero = db.dcComicsColl.findOne({"alias" : "batman"});

hero.gadget = {"car" : "batmobile”};

db.dcComicsColl.update({”aias” : ”batman"}, hero, true);

//java

DbObject query = BasicDBObjectBuilder.start().add("surname",”wayne”).get();

DbObject hero = BasicDBObjectBuilder.start().add("gadget",”batmobile”).get();

dcComicsCollection.update(query, hero, false, true);

//scala

val query = MongoDBObject("name" -> "bruce")

val hero = MongoDBObject("gadget" -> "batmobile")

dcComicsCollection.update(query, hero, true, false)

                        * The blue value it's the upsert, update or insert if not present

                                                                                 Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Querying
//mongo shell

db.dcComicsColl.find({"alias":"batman"}) // all field of the doc

db.dcComicsColl.find({"alias":"batman"},{”surname":1})//surname desc



//java

DBObject query = BasicDBObjectBuilder.start().add("alias", "batman").get();

DBObject out = BasicDBObjectBuilder.start().add("surname", "1").get()

DBCursor cursor = dcComicsColl.find(query, out);



//scala

val query = MongoDBObject("alias" -> "batman")

val obj = dcComicsColl.findOne(query)




                                                              Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Modifier
                             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)




                                               Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Query Criteria

                                 Conditionals
                             $lt $lte $gt $gte


start = new Date("01/01/20111")
db.mycollection.find({"registered" : {"$lt" : start}})


db.dcComicsColl.find({
     "surname":{"$ne":"parker"},
     "name":{"$ne":"peter"}
})


                                                 Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Query Criteria

                              Conditionals

$in $or, $nin, $not <, <=, >, >=, $ne, $mod, $all, $size, $exists




db.attendees.find({”external_num" : {"$nin" : [1356, 525, 874]}})


db.attendees.find({"$or" : [{"ticket_no" : 513}, {"name" : foo}]})




                                              Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Query Regex
                        Perl Compatible Regular Expression
//mongo shell

db.mycollection.find({"name" : /foo?/i})



//java

String pattern = new StringBuilder().append(character).append("*").toString();

DbObject query =BasicDBObjectBuilder.start()

.add("surname", java.util.regex.Pattern.compile(pattern)).get()

List<DBObject> objects = coll.find(query).toArray();



//scala

coll.find(MongoDBObject("surname" -> ".*yne$".r))) {...



                                                             Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Query on array and grouping


         Array inside a document
           $all $size $slice



                Grouping
     count distinct group finalize $key




                                   Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Javascript as part of a query

db.mycollection.find({
 "$where" : function (){
       for (var current in this) {
           ….
       }
 }
})




                                     Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
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})



                        Yes it's a Foursquare feature :)



                                                      Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
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


                                                            Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
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};
}

                                    Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Scaling




          Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Scaling




          Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Shard
Sharding = break up collections into smaller chunks
Splitting data and storing different portions of the data on different machines, also
know as partitioning
The chunks can be distributed across shards so that each shard is responsible for a
subset of the total data set.
A shard is a container that holds a subset of a collection’s data. A shard is either a
single mongod server (for development/testing) or a replica set (for production).
Thus, even if there are many servers in a shard, there is only one master, and all of
the servers contain the same data.
                                                            Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Mongos


The client don't know what shard has what data, or even that data is broken up on
different shards. In front of the shard run routing process called mongos.
This router know when the data are located and the client can see a normal
mongod, like a noshard environment.
This is the router process and comes with all MongoDB distributions. It basically
just routes requests and aggregates responses. It doesn’t store any data or config-
uration information. (Although it does cache information from the config servers.)

                                                         Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Config server


Config servers store the configuration of the cluster: which data is on which shard.
Because mongos doesn’t store anything permanently, it needs somewhere to get
the shard configuration. It syncs this data from the config servers.




                                                          Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
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.
This election process will be initiated by any node that cannot reach the primary.
The highest-priority most-up-to-date server will become the new primary.
The replication is asynchronous

                                                          Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Scala Webapp Demo




                    Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Admin Interface




                  Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Mongo Shell




              Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Mac Client MongoHub




                      Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Books




            http://www.mongodb.org/display/DOCS/Books
        Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
References

●   MongoDB : http://www.mongodb.org/
●   Casbah: https://github.com/mongodb/casbah
●   Salat: https://github.com/novus/salat/
●   Slides scala code example: https://github.com/desmax74/codemotion-2010




                                                    Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
Thanks !
                     Massimiliano Dessì
                 http://jroller.com/desmax
                http://twitter.com/desmax74

           http://www.linkedin.com/in/desmax74
   http://wiki.java.net/bin/view/People/MassimilianoDessi
http://www.jugsardegna.org/vqwiki/jsp/Wiki?MassimilianoDessi
                                              Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna

More Related Content

What's hot

Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in DocumentsMongoDB
 
MongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouchMongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouchWynn Netherland
 
Building a Location-based platform with MongoDB from Zero.
Building a Location-based platform with MongoDB from Zero.Building a Location-based platform with MongoDB from Zero.
Building a Location-based platform with MongoDB from Zero.Ravi Teja
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBUwe Printz
 
Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DBDealing with Azure Cosmos DB
Dealing with Azure Cosmos DBMihail Mateev
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMike Friedman
 
Как мы сделали многопользовательскую браузерную игру для HL++ с воксельной гр...
Как мы сделали многопользовательскую браузерную игру для HL++ с воксельной гр...Как мы сделали многопользовательскую браузерную игру для HL++ с воксельной гр...
Как мы сделали многопользовательскую браузерную игру для HL++ с воксельной гр...Ontico
 
Mongo or Die: How MongoDB Powers Doodle or Die
Mongo or Die: How MongoDB Powers Doodle or DieMongo or Die: How MongoDB Powers Doodle or Die
Mongo or Die: How MongoDB Powers Doodle or DieAaron Silverman
 
MongoDC 2012: How MongoDB Powers Doodle or Die
MongoDC 2012: How MongoDB Powers Doodle or DieMongoDC 2012: How MongoDB Powers Doodle or Die
MongoDC 2012: How MongoDB Powers Doodle or DieMongoDB
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationMongoDB
 
Back to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBBack to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBMongoDB
 
Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patternsjoergreichert
 
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 ApplicationMongoDB
 
MongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective IndexingMongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective IndexingMongoDB
 
MongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB Launchpad 2016: What’s New in the 3.4 ServerMongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB Launchpad 2016: What’s New in the 3.4 ServerMongoDB
 
Back to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsBack to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsJoe Drumgoole
 
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'tsThe Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'tsMatias Cascallares
 

What's hot (20)

Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in Documents
 
MongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouchMongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouch
 
Building a Location-based platform with MongoDB from Zero.
Building a Location-based platform with MongoDB from Zero.Building a Location-based platform with MongoDB from Zero.
Building a Location-based platform with MongoDB from Zero.
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDB
 
NoSQL databases
NoSQL databasesNoSQL databases
NoSQL databases
 
Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DBDealing with Azure Cosmos DB
Dealing with Azure Cosmos DB
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
 
MongoDB Webtech conference 2010
MongoDB Webtech conference 2010MongoDB Webtech conference 2010
MongoDB Webtech conference 2010
 
Как мы сделали многопользовательскую браузерную игру для HL++ с воксельной гр...
Как мы сделали многопользовательскую браузерную игру для HL++ с воксельной гр...Как мы сделали многопользовательскую браузерную игру для HL++ с воксельной гр...
Как мы сделали многопользовательскую браузерную игру для HL++ с воксельной гр...
 
Mongo or Die: How MongoDB Powers Doodle or Die
Mongo or Die: How MongoDB Powers Doodle or DieMongo or Die: How MongoDB Powers Doodle or Die
Mongo or Die: How MongoDB Powers Doodle or Die
 
MongoDC 2012: How MongoDB Powers Doodle or Die
MongoDC 2012: How MongoDB Powers Doodle or DieMongoDC 2012: How MongoDB Powers Doodle or Die
MongoDC 2012: How MongoDB Powers Doodle or Die
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB Application
 
Back to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBBack to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDB
 
Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patterns
 
2012 phoenix mug
2012 phoenix mug2012 phoenix mug
2012 phoenix mug
 
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 .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective IndexingMongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
 
MongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB Launchpad 2016: What’s New in the 3.4 ServerMongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB Launchpad 2016: What’s New in the 3.4 Server
 
Back to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsBack to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in Documents
 
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'tsThe Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
 

Viewers also liked

May 2010 - Hibernate search
May 2010 - Hibernate searchMay 2010 - Hibernate search
May 2010 - Hibernate searchJBug Italy
 
Escape From Amazon: Tips/Techniques for Reducing AWS Dependencies
Escape From Amazon: Tips/Techniques for Reducing AWS DependenciesEscape From Amazon: Tips/Techniques for Reducing AWS Dependencies
Escape From Amazon: Tips/Techniques for Reducing AWS DependenciesSoam Acharya
 
Three languages in thirty minutes
Three languages in thirty minutesThree languages in thirty minutes
Three languages in thirty minutesMassimiliano Dessì
 
May 2010 - Infinispan
May 2010 - InfinispanMay 2010 - Infinispan
May 2010 - InfinispanJBug Italy
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBossJBug Italy
 
Embedding social media to effectively support OU learning with Eric Stoller
Embedding social media to effectively support OU learning with Eric StollerEmbedding social media to effectively support OU learning with Eric Stoller
Embedding social media to effectively support OU learning with Eric StollerOpen University
 
JBoss Wise: breaking barriers to WS testing
JBoss Wise: breaking barriers to WS testingJBoss Wise: breaking barriers to WS testing
JBoss Wise: breaking barriers to WS testingJBug Italy
 

Viewers also liked (8)

May 2010 - Hibernate search
May 2010 - Hibernate searchMay 2010 - Hibernate search
May 2010 - Hibernate search
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
Escape From Amazon: Tips/Techniques for Reducing AWS Dependencies
Escape From Amazon: Tips/Techniques for Reducing AWS DependenciesEscape From Amazon: Tips/Techniques for Reducing AWS Dependencies
Escape From Amazon: Tips/Techniques for Reducing AWS Dependencies
 
Three languages in thirty minutes
Three languages in thirty minutesThree languages in thirty minutes
Three languages in thirty minutes
 
May 2010 - Infinispan
May 2010 - InfinispanMay 2010 - Infinispan
May 2010 - Infinispan
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBoss
 
Embedding social media to effectively support OU learning with Eric Stoller
Embedding social media to effectively support OU learning with Eric StollerEmbedding social media to effectively support OU learning with Eric Stoller
Embedding social media to effectively support OU learning with Eric Stoller
 
JBoss Wise: breaking barriers to WS testing
JBoss Wise: breaking barriers to WS testingJBoss Wise: breaking barriers to WS testing
JBoss Wise: breaking barriers to WS testing
 

Similar to MongoDB dessi-codemotion

Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Dbchriskite
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHPHow to use MongoDB with CakePHP
How to use MongoDB with CakePHPichikaway
 
Starting with MongoDB
Starting with MongoDBStarting with MongoDB
Starting with MongoDBDoThinger
 
Introduction to NoSQL Database
Introduction to NoSQL DatabaseIntroduction to NoSQL Database
Introduction to NoSQL DatabaseMohammad Alghanem
 
MongoDB at Scale
MongoDB at ScaleMongoDB at Scale
MongoDB at ScaleMongoDB
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRailsMike Dirolf
 
Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)MongoDB
 
Mongodb intro
Mongodb introMongodb intro
Mongodb introchristkv
 
mongodb-introduction
mongodb-introductionmongodb-introduction
mongodb-introductionTse-Ching Ho
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBAlex Bilbie
 
Geo & capped collections with MongoDB
Geo & capped collections  with MongoDBGeo & capped collections  with MongoDB
Geo & capped collections with MongoDBRainforest QA
 
MongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behlMongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behlTO THE NEW | Technology
 
Superficial mongo db
Superficial mongo dbSuperficial mongo db
Superficial mongo dbDaeMyung Kang
 
Accra MongoDB User Group
Accra MongoDB User GroupAccra MongoDB User Group
Accra MongoDB User GroupMongoDB
 
introtomongodb
introtomongodbintrotomongodb
introtomongodbsaikiran
 
PHP Development With MongoDB
PHP Development With MongoDBPHP Development With MongoDB
PHP Development With MongoDBFitz Agard
 
PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)MongoSF
 

Similar to MongoDB dessi-codemotion (20)

Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Db
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHPHow to use MongoDB with CakePHP
How to use MongoDB with CakePHP
 
Starting with MongoDB
Starting with MongoDBStarting with MongoDB
Starting with MongoDB
 
mongodb tutorial
mongodb tutorialmongodb tutorial
mongodb tutorial
 
Introduction to NoSQL Database
Introduction to NoSQL DatabaseIntroduction to NoSQL Database
Introduction to NoSQL Database
 
MongoDB at Scale
MongoDB at ScaleMongoDB at Scale
MongoDB at Scale
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRails
 
Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
mongodb-introduction
mongodb-introductionmongodb-introduction
mongodb-introduction
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Geo & capped collections with MongoDB
Geo & capped collections  with MongoDBGeo & capped collections  with MongoDB
Geo & capped collections with MongoDB
 
MongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behlMongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behl
 
Superficial mongo db
Superficial mongo dbSuperficial mongo db
Superficial mongo db
 
Accra MongoDB User Group
Accra MongoDB User GroupAccra MongoDB User Group
Accra MongoDB User Group
 
MongoDB
MongoDBMongoDB
MongoDB
 
introtomongodb
introtomongodbintrotomongodb
introtomongodb
 
PHP Development With MongoDB
PHP Development With MongoDBPHP Development With MongoDB
PHP Development With MongoDB
 
PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)
 
Einführung in MongoDB
Einführung in MongoDBEinführung in MongoDB
Einführung in MongoDB
 

More from Massimiliano Dessì

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...Massimiliano Dessì
 
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 Massimiliano Dessì
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudMassimiliano Dessì
 
Web Marketing Training 2014 Community Online
Web Marketing Training 2014 Community OnlineWeb Marketing Training 2014 Community Online
Web Marketing Training 2014 Community OnlineMassimiliano Dessì
 
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 JVMMassimiliano Dessì
 
Reactive applications Linux Day 2013
Reactive applications Linux Day 2013Reactive applications Linux Day 2013
Reactive applications Linux Day 2013Massimiliano Dessì
 
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 MVCMassimiliano Dessì
 
Codemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_sprayCodemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_sprayMassimiliano Dessì
 
Why we cannot ignore functional programming
Why we cannot ignore functional programmingWhy we cannot ignore functional programming
Why we cannot ignore functional programmingMassimiliano Dessì
 
Jaxitalia09 Spring Best Practices
Jaxitalia09 Spring Best PracticesJaxitalia09 Spring Best Practices
Jaxitalia09 Spring Best PracticesMassimiliano Dessì
 
MongoDB Scala Roma SpringFramework Meeting2009
MongoDB Scala Roma SpringFramework Meeting2009MongoDB Scala Roma SpringFramework Meeting2009
MongoDB Scala Roma SpringFramework Meeting2009Massimiliano 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
 
Web Marketing Training 2014 Community Online
Web Marketing Training 2014 Community OnlineWeb Marketing Training 2014 Community Online
Web Marketing Training 2014 Community Online
 
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
 
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
 
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
 
Scala linux day 2012
Scala linux day 2012 Scala linux day 2012
Scala linux day 2012
 
Spring Roo Internals Javaday IV
Spring Roo Internals Javaday IVSpring Roo Internals Javaday IV
Spring Roo Internals Javaday IV
 
Spring Roo JaxItalia09
Spring Roo JaxItalia09Spring Roo JaxItalia09
Spring Roo JaxItalia09
 
Jaxitalia09 Spring Best Practices
Jaxitalia09 Spring Best PracticesJaxitalia09 Spring Best Practices
Jaxitalia09 Spring Best Practices
 
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
 

Recently uploaded

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 SolutionsEnterprise Knowledge
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
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 MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

MongoDB dessi-codemotion

  • 1. Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 2. Speaker Software architect/developer Pronetics/Sourcesense Founder Spring Italian User Group Chairman JugSardegna Committer/Contributor OpenNMS - MongoDB Author Spring 2.5 Aspect Oriented Programming Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 3. MongoDB Philosophy Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 4. Some MongoDB production deployments http://www.mongodb.org/display/DOCS/Production+Deployments Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 5. Main Features ● Document Oriented ● Easy scalability - Documents (objects) map nicely to programming language data types - "slaveOK" reads are distributed over replicated servers - Dynamically-typed (schemaless) for easy schema evolution - Automatic sharding (auto-partitioning of data across servers) - No joins and no transactions for high performance - Reads and writes are distributed over shards and easy scalability - No joins and no transactions make distributed queries easy and fast ● High Performance ● High Availability - No joins and no transactions makes reads and writes fast - Replicated servers with automatic master failover - Indexes with indexing into embedded documents and arrays ● Indexing - Optional asynchronous writes ● Stored JavaScript ● Rich Query Language ● Fixed-size collection ● File storage ● MapReduce Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 6. No Sql Injection Mongo is invulnerable to injection attacks, no code execution Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 7. Document as Basic unit of Data in BSON (Binary JSON) format { "name" : "MongoDB", "info" : { "storage" : "Binary JSON (BSON)", "full index" : "true", Document: an Ordered set of keys with associated values "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” } "greeting": {"international" : "Hello, world!", "italy" :"Ciao Mondo !" } }, "_id” : "024x6f279578a64bb0666945" Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 8. Grouping SQL Table contains Rows MONGO Collection and subcollections contains Documents * Document Limit: Larger than 4 Mb, the entire text of War and Peace is 3.14Mb Collection are are created dynamically and automatically grow in size to fit additional data Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 9. A single instance of MongoDB can host multiple independent databases, each of which can have its own collections and permissions. Photo from http://www.aibento.net/ Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 10. No Join's cost ● SQL SELECT * FROM posts INNER JOIN posts_tags ON posts.id = posts_tags.post_id INNER JOIN tags ON posts_tags.tag_id == tags.id WHERE tags.text = 'politics' AND posts.vote_count > 10; ● MONGO db.posts.find({'tags': 'politics', 'vote_count': {'$gt': 10}}); Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 11. Collections Schema free Documents within a single collection can have any number of different "shapes” In theory, each document in a collection can have a completely different structure; in practice, a collection's documents will be relatively uniform. Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 12. 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 Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 13. Common operations Fastest : Fire and Forget Command with response : getLastError Examples with Server side Javascript via mongo shell Java via MongoDB Official 10gen Driver Scala via Casbah Official 10gen scala driver + Salat serializer Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 14. Inserting //mongo shell db.dcComicsCollection.insert({"name" : "bruce", "surname" : "wayne", "alias" : "batman"}) //Java Map fields = batman.toMap() dcComicsCollection.insert(BasicDBObjectBuilder.start(fields).get()) //java driver //scala dcComicsCollection.insert(grater[BlogPost].asDBObject(post)) Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 15. Removing //mongo shell db.dcComicsCollection.delete({"alias" : "superman"}) //java Map query = batman.getMap() DBObject obj = BasicDBObjectBuilder.start(fields).get() dcComicsColl.remove(obj); //scala dcComicsCollection.remove(grater[BlogPost].asDBObject(post) Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 16. Updating (The schema can be changed dinamically) //mongo shell var hero = db.dcComicsColl.findOne({"alias" : "batman"}); hero.gadget = {"car" : "batmobile”}; db.dcComicsColl.update({”aias” : ”batman"}, hero, true); //java DbObject query = BasicDBObjectBuilder.start().add("surname",”wayne”).get(); DbObject hero = BasicDBObjectBuilder.start().add("gadget",”batmobile”).get(); dcComicsCollection.update(query, hero, false, true); //scala val query = MongoDBObject("name" -> "bruce") val hero = MongoDBObject("gadget" -> "batmobile") dcComicsCollection.update(query, hero, true, false) * The blue value it's the upsert, update or insert if not present Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 17. Querying //mongo shell db.dcComicsColl.find({"alias":"batman"}) // all field of the doc db.dcComicsColl.find({"alias":"batman"},{”surname":1})//surname desc //java DBObject query = BasicDBObjectBuilder.start().add("alias", "batman").get(); DBObject out = BasicDBObjectBuilder.start().add("surname", "1").get() DBCursor cursor = dcComicsColl.find(query, out); //scala val query = MongoDBObject("alias" -> "batman") val obj = dcComicsColl.findOne(query) Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 18. Modifier 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) Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 19. Query Criteria Conditionals $lt $lte $gt $gte start = new Date("01/01/20111") db.mycollection.find({"registered" : {"$lt" : start}}) db.dcComicsColl.find({ "surname":{"$ne":"parker"}, "name":{"$ne":"peter"} }) Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 20. Query Criteria Conditionals $in $or, $nin, $not <, <=, >, >=, $ne, $mod, $all, $size, $exists db.attendees.find({”external_num" : {"$nin" : [1356, 525, 874]}}) db.attendees.find({"$or" : [{"ticket_no" : 513}, {"name" : foo}]}) Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 21. Query Regex Perl Compatible Regular Expression //mongo shell db.mycollection.find({"name" : /foo?/i}) //java String pattern = new StringBuilder().append(character).append("*").toString(); DbObject query =BasicDBObjectBuilder.start() .add("surname", java.util.regex.Pattern.compile(pattern)).get() List<DBObject> objects = coll.find(query).toArray(); //scala coll.find(MongoDBObject("surname" -> ".*yne$".r))) {... Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 22. Query on array and grouping Array inside a document $all $size $slice Grouping count distinct group finalize $key Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 23. Javascript as part of a query db.mycollection.find({ "$where" : function (){ for (var current in this) { …. } } }) Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 24. 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}) Yes it's a Foursquare feature :) Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 25. 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 Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 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}; } Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 27. Scaling Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 28. Scaling Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 29. Shard Sharding = break up collections into smaller chunks Splitting data and storing different portions of the data on different machines, also know as partitioning The chunks can be distributed across shards so that each shard is responsible for a subset of the total data set. A shard is a container that holds a subset of a collection’s data. A shard is either a single mongod server (for development/testing) or a replica set (for production). Thus, even if there are many servers in a shard, there is only one master, and all of the servers contain the same data. Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 30. Mongos The client don't know what shard has what data, or even that data is broken up on different shards. In front of the shard run routing process called mongos. This router know when the data are located and the client can see a normal mongod, like a noshard environment. This is the router process and comes with all MongoDB distributions. It basically just routes requests and aggregates responses. It doesn’t store any data or config- uration information. (Although it does cache information from the config servers.) Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 31. Config server Config servers store the configuration of the cluster: which data is on which shard. Because mongos doesn’t store anything permanently, it needs somewhere to get the shard configuration. It syncs this data from the config servers. Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 32. 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. This election process will be initiated by any node that cannot reach the primary. The highest-priority most-up-to-date server will become the new primary. The replication is asynchronous Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 33. Scala Webapp Demo Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 34. Admin Interface Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 35. Mongo Shell Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 36. Mac Client MongoHub Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 37. Books http://www.mongodb.org/display/DOCS/Books Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 38. References ● MongoDB : http://www.mongodb.org/ ● Casbah: https://github.com/mongodb/casbah ● Salat: https://github.com/novus/salat/ ● Slides scala code example: https://github.com/desmax74/codemotion-2010 Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna
  • 39. Thanks ! Massimiliano Dessì http://jroller.com/desmax http://twitter.com/desmax74 http://www.linkedin.com/in/desmax74 http://wiki.java.net/bin/view/People/MassimilianoDessi http://www.jugsardegna.org/vqwiki/jsp/Wiki?MassimilianoDessi Massimiliano Dessì – desmax74@yahoo.it – Jug Sardegna