Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Mongo db

3,612 views

Published on

An introduction to querying in mongodb.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Mongo db

  1. 1. Athira Mukundan Solution Consultant @Sahaj athira_tech@yahoo.in
  2. 2. THE CAP THEOREM
  3. 3. What’s the big deal? Scalable High-Performance Open-source,Document-oriented database Built for Speed Rich Document based queries for Easy readability Full Index Support for High Performance Replication and Failover for High Availability Auto Sharding for Easy Scalability Geo-spatial Indexes for Geo-spatial queries Map / Reduce for Aggregation
  4. 4. MongoDB in the RDBMS terms SQL Terms/Concepts MongoDB Terms/Concepts Database Database Table Collection Row Document Column Field Table Joins Embedding and Linking
  5. 5. Let’s do some Crud Create: Update: Delete: db.users.insert({name: “Alec”, place: “Bangalore”}) db.users.update({name: “Alec”}, place: “Mumbai”}) db.users.remove({name: “Alec”})
  6. 6. Mastering Find Field Selection Ordering Paging Count db.users.find({}, {name: 1}) db.users.find().sort({name: 1}) db.users.find().sort({salary: -1}).limit(2).skip(1) db.users.count({salary: {$gt: 50}})
  7. 7. Mastering Selectors $lt, $lte, $gt, $gte, $ne $exist $in $or db.users.find({name: “Alec”, weight:{$gt: 70}}) db.users.find({weight: {$exists: false}}) db.users.find({managers: {$in: [‘Sam’, ‘Philip’]}}) db.users.find(weight:{$gt: 70}, $or: {height: {$gt: 170}})
  8. 8. Indexing and Aggregation Indexing Aggregates: $group, $sort, $sum, $avg, $min, $max db.testdb.ensureIndex({"age" : 1, "account" : 1}) db.testdb.dropIndex(“index_name”) db.testdb.aggregate([{$group : {_id : "$author", num_recipes : {$sum : 1}}}]) db.testdb.aggregate([{$group: {_id: "$author", num_likes: {$min: "$likes"}}}])
  9. 9. Map Reduce A data processing paradigm for condensing large volumes of data into useful aggregated results MapReduce is generally used for processing large data sets. db.collection.mapReduce( function() {emit(key,value);}, //map function function(key,values) {return reduceFunction}, //reduce function { out: collection, query: document, sort: document, limit: number })
  10. 10. Replication Sets
  11. 11. Sharding

×