How I prepared for C100DEV: MongoDB Certified Developer Associate Exam

Mongo DB Developer Course from MongoDB University


Units
Topics



Week 1: IntroductionOverview, Design Goals, the Mongo Shell, JSON Intro, Installing Tools, Overview of Blog Project. Maven, Spark and Freemarker Intro


Week 2: CRUDMongo Shell, Query Operators, Update Operators and a Few Commands



Week 3: Schema DesignPatterns, Case Studies & Tradeoffs



Week 4: PerformanceUsing Indexes, Monitoring And Understanding Performance. Performance In Sharded Environments



Week 5: Aggregation FrameworkGoals, The Use Of The Pipeline, Comparison With SQL Facilities.



Week 6: Application EngineeringDrivers, Impact Of Replication And Sharding On Design And Development.



Week 7: Case StudiesInterview with Jon Hoffman, foursquare and Interview with Ryan Bubunksi, codecademy









Mongo DB Documentation:

http://docs.mongodb.org/manual/core/crud-introduction/


https://university.mongodb.com/exams/C100DEV/about

Required MongoDB Knowledge

  • Philosophy & Features: features and performance, JSON, BSON, fault tolerance, disaster recovery, horizontal scaling, and the Mongo shell
  • CRUD: Create, Read, Update, and Delete operations
  • Data Modeling: embedding, references, document growth, modeling one-to-one and one-to-many relationships, modeling for atomic operations, modeling tree structures
  • Indexing: single key, compound, multi-key, geospatial indexes and queries, unique indexes, and performance
  • Aggregation: pipeline, operators, memory usage, sort, skip, and limit
  • Replication: concepts and components, write concern, elections, and failover
  • Sharding: concepts and components, shard keys, and hashed shard keys

After completing the course I started with MongoDB definitive Guide by : Kristina Chodorow. Good is easy to learn the concepts and do a good practise.

http://shop.oreilly.com/product/0636920028031.do






Prep Notes:

Query:
db.blog.posts.insert([{"content":"This  is my blog","comments":[{"comment":"good post","author":"John","votes":0},{"comment":"i tought it was too short","author":"Claire","votes":3},{"comment":"free watches","author":"Alice","votes":-1}]}])

Result:
db.blog.posts.find().pretty()
{
"_id" : ObjectId("54487a802b56097402b6cde3"),
"content" : "This  is my blog",
"comments" : [
{
"comment" : "good post",
"author" : "John",
"votes" : 0
},
{
"comment" : "i tought it was too short",
"author" : "Claire",
"votes" : 3
},
{
"comment" : "free watches",
"author" : "Alice",
"votes" : -1
}
]
}

$inc for incrementing the integer value in a collection


db.blog.posts.update({"content":"This  is my blog"},{"$inc":{"comments.0.votes":1}})

By using $ only the first occurrence of John would be replaced to Jim.

db.blog.posts.update({"comments.author":"John"},{"$set":{"comments.$.author":"Jim"}})

Upsert is some thing which gets inserted while we do an update
db.users.update({"rep" : 25}, {"$inc" : {"rep" : 3}}, true)


setOnInsert is used for a field which gets set and it's values cannot be changed further:
db.users.update({}, {"$setOnInsert" : {"createdAt" : new Date()}}, true)


save function:
save is a shell function that lets you insert a document if it doesn't exist and update if it does.

Updating multiple documents:
The 4th arguments true means update all matched documents. If false is passed first matched document would be updated.
db.users.update({"birthday" : "10/13/1978"},{"$set" : {"gift" : "Happy Birthday!"}}, false, true)


Here n=5 means that 5 records were affected in the last query:
db.runCommand({getLastError : 1})
{
"err" : null,
"updatedExisting" : true,
"n" : 5,
"ok" : true
}

Inorder to get the last updated document we can use the findAndModify command. 

Write concern is a client setting used to describe how safely a write should be stored
before the application continues. The two basic write concerns are acknowledged or unacknowledged writes.