Taking An Exam: Proctoring
Taking An Exam: Proctoring
Taking an Exam
You are about to take a MongoDB Certification Exam. We want you to be successful so we've prepared this
guide to help you study. With a good understanding of the subjects covered here, you should be well
prepared to pass. Good luck!
Proctoring
You will take the exam at home, at your computer. When you take the exam, there will be a live proctor from
our partner, Examity, observing. He or she will take you through the steps, help you begin your test, and will
let you know if anything is out of order so you don't violate exam rules without knowing it.
Your Computer
Your computer must be a Windows PC or Mac (Sorry, no Linux yet!) with a video camera (webcam), a
microphone, and speakers. The webcam can be built-in or it can be a peripheral, but you need to be able to
position it so that the proctor can see your face throughout the exam. You must be able to pivot the camera
(possibly by picking up your laptop) so that the proctor can see everything in the room including your desk.
You can't use headphones, but do need to use speakers so that you can hear the proctor.
Before you even schedule the exam, please go through Examity's Computer Readiness Check
(http://prod.examity.com/systemcheck/computerreadinesscheck.aspx). This will tell you if there are any
problems with your webcam, your internet connection, your microphone, etc. If you are going to have
problems, it's best to find out early.
You need to be alone when taking the exam. No one else should be in the room. You may not have any
reference materials present and your desk area must be free of clutter. This will be verified by the proctor
before the exam begins. You may take the exam at any time during the exam session for which you are
registered, day or night. Exam sessions run for one week. They typically begin and end at 17:00 UTC on a
Tuesday, but be sure to check the about page for your exam (DBA
(https://university.mongodb.com/exams/C100DBA/about) or Developer
(https://university.mongodb.com/exams/C100DEV/about)) for the exact times.
There is no penalty for guessing, so you should have an answer for every problem. If you find that you are
getting close to running out of time, be sure to run through and provide an answer for each question. Leaving
questions blank will guarantee that you don't get credit.
Translation Software
You may use translation software in order to translate the questions from English to another language. We do
not support any particular translation software. We do not vouch for the translation accuracy of any software.
However, you are welcome to use the translation software of your choice during the test if you are willing to
assume any risks associated with the software.
Introduction
This section will describe the foundational computing concepts with which you should be familiar. You should
consider these to be prerequisites to understanding MongoDB. We do not teach these directly in our
curriculum, but some questions on the exam assume knowledge of these concepts. You can find detailed
information on these subjects in computer science textbooks or through a little Googling.
It is expected that you will understand broadly what a database is, specifically:
For the exam, you should have a working understanding of the following:
Physical memory
Virtual memory
Memory mapping
Hexidecimal (base-16) representations of data
JSON
Resources:
Videos:
Introduction to JSON (https://university.mongodb.com/videos/y/PTATjNSjbJ0)
JSON revisited (https://university.mongodb.com/videos/y/CTffxoSSLqg)
JSON spec (https://university.mongodb.com/videos/y/kOrsT94-A28)
Docs:
Intro to JSON (//docs.mongodb.org/manual/reference/mongodb-extended-json/)
External links:
json.org (http://json.org/)
BSON
Resource:
Resources:
Video:
Lesson video (https://university.mongodb.com/videos/y/e18vCIdQKp4)
Docs:
Getting Started with the mongo Shell (//docs.mongodb.org/manual/tutorial/getting-started-with-
the-mongo-shell/)
mongo Shell Quick Reference (//docs.mongodb.org/manual/reference/mongo-shell/)
You should also know how to work with data types in the shell (//docs.mongodb.org/manual/core/shell-
types/).
Shell Examples
To assign a value to a variable, you use the '=' sign. Let's assign the value of 5 to the 'x' variable:
> var x = 5;
> print(x)
5
JavaScript is lax about syntax so the following will also work. Note the lack of the var keyword and
semicolons.
> x = 5
5
> print(x)
5
JavaScript and the shell include a number of built-in objects and functions that support a variety of uses. For
example, Math is a built-in class with methods supporting a number of common mathematical operations.
ISODate is another class commonly used when date objects are required.
> Math.floor(3.5)
3
> Math.PI
3.141592653589793
> ISODate()
ISODate("2015-07-22T19:04:34.219Z")
> print("hello")
hello
>
Iteration in the shell (and in JavaScript in general) has the following syntax. Here we are using the most
compact form. You may choose to write loops such as this with each statement and the curly braces on
separate lines.
> var x = 0
> while ( x < 5 ) { x++; print(x) }
1
2
3
4
5
> for (i=0; i<=3; i++) { print(i) }
0
1
2
3
> x = { a : 4, b : 3, c : 2 }
{ "a" : 4, "b" : 3, "c" : 2 }
> for (key in x) { print(key + ': ' + x[key]) }
a: 4
b: 3
c: 2
>
In the mongo shell (and drivers), you will work with database handles and collection objects.
> db
test
> db.currentOP()
{ "inprog" : [ ] }
> db.people.find()
{ "_id" : ObjectId("55afeb6a6daadd6baf25c63b"), "name" : "Dwight", "title" : "Chair of t
he Board" }
{ "_id" : ObjectId("55afeb7b6daadd6baf25c63c"), "name" : "Andrew", "title" : "VP of Deve
loper Experience" }
Shell Exercises
The following are exercises you may find useful in ensuring you understand the above.
Write a for loop that inserts one million documents in the mongo shell.
Create one collection with a field that contains the _id of documents in second collection. Perform a
series of find operations that use the results of a query against the first collection to identify the _ids of
documents to retrieve from the second collection.
Resources:
Webinar:
Scaling MongoDB Webinar Series (https://www.mongodb.com/lp/webinar/scaling-series-sept-
2014)
Docs:
Sharding Introduction (//docs.mongodb.org/manual/core/sharding-introduction/)
The features typically found relational database management systems that MongoDB does not include
for scalability reasons
How relational data models typically differ from data models in MongoDB
Resources:
Video:
MongoDB and Relational Databases (https://university.mongodb.com/videos/y/-KIC1LXxcGM)
Docs:
SQL to MongoDB Mapping Chart (//docs.mongodb.org/manual/reference/sql-comparison/)
MongoDB.com:
Compare MongoDB and MySQL (https://www.mongodb.com/compare/mongodb-mysql)
Resources:
Video:
MongoDB is Schemaless (https://university.mongodb.com/videos/y/uKB-Hoqs6zI)
Docs:
Data Modeling Introduction (http://docs.mongodb.org/master/core/data-modeling-introduction/)
Sample Problems
1. Which features of relational database management systems were deliberately omitted in MongoDB and
help us to obtain horizontal scalability? Check all that apply.
a. Multi-statement transactions
b. Authentication
c. Joins
2. In order to ensure that you can maintain high availability in the face of server failure, you should
implement which of the following?
a. Replication
b. Sharding
c. The proper storage engine
d. Properly defined user roles
e. Put indexes on all of your documents
3. Which of the following are common uses of the mongo shell? Check all that apply.
a. Perform queries against MongoDB collections
b. Perform administrative tasks
c. Use as a JavaScript framework for your production system
1. a, c
2. a
3. a, b
Consider a simple JSON document and determine how it will be encoded as BSON.
Write a simple routine in JavaScript that creates and inserts some sample data into a collection.
Experiment with a few find operations to ensure the data was inserted correctly.
CRUD
In the CRUD section of the certification exam, we will verify that you:
Understand all create, read, update, and delete (CRUD) operations in the MongoDB query language
Are familiar with commonly used CRUD operators and how to use them
Know what data types MongoDB supports
In this section, we are not testing that you have the MongoDB query language syntax memorized. However,
you should be able to distinguish correctly written queries from those that are not. You should also know
which query parameters are necessary versus those that are optional and how to use query parameters. We
will not expect you to have query operators memorized, but you should be able to recognize the correct
operator for a task from a set of choices.
Create
Properly use the insert, save, update, and findAndModify commands to create new documents
Match insert commands with descriptions of what they do
Know how to perform bulk inserts
Understand the uniqueness constraint of _id fields and its implications for CRUD operations
Understand how ObjectIds are created and used in MongoDB
db.collection.insert()
Docs:
db.collection.insert() (//docs.mongodb.org/manual/reference/method/db.collection.insert/)
Inserting Documents Tutorial (//docs.mongodb.org/manual/tutorial/insert-documents/)
Video:
Inserting Documents (https://university.mongodb.com/videos/y/qqfVxGLIrLg)
db.collection.save() will cause a document to be inserted if the _id is not included, or the _id doesn't
match any documents.
Docs:
db.collection.save() (//docs.mongodb.org/manual/reference/method/db.collection.save/)
Video:
The Save Command (https://university.mongodb.com/videos/y/fWLiwAC-Q20)
db.collection.update() will insert documents in some circumstances ("upserts").
Docs:
Upsert (//docs.mongodb.org/manual/reference/method/db.collection.update/) (only an insert
if upsert: true is set)
Video:
Upsert lesson video (https://university.mongodb.com/videos/y/Dy2p8k3EZs4)
db.collection.findAndModify() can result in an insert if updating and "upsert" is set to true.
Docs:
db.collection.findAndModify()
(//docs.mongodb.org/manual/reference/method/db.collection.findAndModify/)
Most questions about document creation will involve the db.collection.insert() command. Inserts are typically
straightforward.
Upserts can be more complicated. In the example below, assume the foo collection does not already contain
a document with a=5 and b<=7.
In cases such as this, a new document is inserted. In this specific case, the new document contains the
value, c : 8, because the upsert instructed that it be set. The query document also contributes fields to the
document that gets created. In this case, a : 5 was also be set. The value of b could not be determined from
the query, so it will not be set. Finally, an ObjectId was assigned to the _id field.
You should also be familiar with the special properties of the _id field:
Docs:
The _id Field (//docs.mongodb.org/manual/core/document/#the-id-field)
The _id Field (//docs.mongodb.org/manual/reference/method/db.collection.insert/#id-field)
Video:
Compound _id Fields (https://university.mongodb.com/videos/y/zoN4cj_XQzY)
Read
In MongoDB, you read documents using either the db.collection.find() method, or the
db.collection.findAndModify() method. You should be familiar with both commands, but the .find() method will
receive greater coverage on the exam.
db.collection.find()
Docs:
db.collection.find() (//docs.mongodb.org/manual/reference/method/db.collection.find/)
find() tutorial (//docs.mongodb.org/manual/tutorial/query-documents/)
Videos:
Introduction to find() (https://university.mongodb.com/videos/y/8kKfFK6a0Ak)
Query by Matching (https://university.mongodb.com/videos/y/UIg86QjSoyY)
Operators for db.collection.find():
$lt and $gt (https://university.mongodb.com/videos/y/FHLrz4VGzkg)
string inequalities (https://university.mongodb.com/videos/y/imCCKOevU3c)
$regex, $exists, $type (https://university.mongodb.com/videos/y/lI-jhqYf1JY)
$or (https://university.mongodb.com/videos/y/BW5ElNCRZps)
$and (https://university.mongodb.com/videos/y/hYk7pjgjjzc)
Array Operators:
Querying Inside Arrays (https://university.mongodb.com/videos/y/jvEqwW75Bus)
$in and $all (https://university.mongodb.com/videos/y/QU2NrkviORE)
Dot Notation (https://university.mongodb.com/videos/y/NrjFECIfwqk)
Docs:
Cursors (//docs.mongodb.org/manual/core/cursors/)
Cursor tutorial (//docs.mongodb.org/manual/tutorial/iterate-a-cursor/)
Videos:
Cursor lesson (https://university.mongodb.com/videos/y/3jA6iFSEJOI)
There are other collection read methods that will not return cursors, but with which you should be familiar.
db.collection.count()
Docs:
count() (//docs.mongodb.org/manual/reference/method/db.collection.count/)
Videos:
count() lesson (https://university.mongodb.com/videos/y/eKD5bVmNQMI)
db.collection.distinct()
Docs:
distinct() (//docs.mongodb.org/manual/reference/method/db.collection.distinct/)
There are other methods that can be applied to cursors themselves. These can return a number (e.g., count),
or they can modify the result set (i.e., sort, skip, and limit). You may also be expected to know how to
manually iterate a cursor. See the MongoDB documentation for a list of cursor methods
(//docs.mongodb.org/manual/reference/method/js-cursor/)
cursor.count()
Works like collection.count()
Docs:
cursor.count() (//docs.mongodb.org/manual/reference/method/cursor.count/)
Videos:
cursor.count() (https://university.mongodb.com/videos/y/eKD5bVmNQMI)
cursor.sort()
Sort documentation (//docs.mongodb.org/manual/reference/method/cursor.sort/)
Lesson on sort, skip, and limit (https://university.mongodb.com/videos/y/BsmQ4SNCikc)
Second lesson on sorting (https://university.mongodb.com/videos/y/hwUg8r7a-d8)
cursor.skip()
Skip documentation (//docs.mongodb.org/manual/reference/method/cursor.skip/)
Lesson on sort, skip, and limit (https://university.mongodb.com/videos/y/BsmQ4SNCikc)
cursor.limit()
Limit documentation (//docs.mongodb.org/manual/reference/method/cursor.limit/)
Lesson on sort, skip, and limit (https://university.mongodb.com/videos/y/BsmQ4SNCikc)
cursor.next()
Next documentation (//docs.mongodb.org/manual/tutorial/iterate-a-cursor/)
The lesson on cursors, above, reproduced here
(https://university.mongodb.com/videos/y/3jA6iFSEJOI), also shows how to do this
You can also project your results in order to limit the fields you get back.
Finally, you can bulk insert by passing an array to db.collection.insert(). You should know the difference
between ordered and unordered bulk inserts.
Docs:
Update
Updates modify existing documents. For the exam, you should be able to:
Properly use the save, update, and findAndModify commands to mutate existing documents
Distinguish which parameter finds the documents to change, which mutates them
Explain the behavior of any update operator with which you are presented
Recognize when upserts and db.collection.save() will insert documents
Updates can occur with a few collection methods, some of which were in the insert section:
db.collection.save()
This will update if the _id is specified and it matches an existing document.
save() documentation (//docs.mongodb.org/manual/reference/method/db.collection.save/)
save() lesson video (https://university.mongodb.com/videos/y/fWLiwAC-Q20)
db.collection.findAndModify()
findAndModify() documentation
(//docs.mongodb.org/manual/reference/method/db.collection.findAndModify/)
db.collection.update()
This will update unless upsert: true is specified and the query matches no documents.
update() documentation (//docs.mongodb.org/manual/reference/method/db.collection.update/)
update() tutorial (//docs.mongodb.org/manual/tutorial/modify-documents/)
With no operators specified in the update parameter, there will be a wholesale update
Wholesale Update Lesson Video (https://university.mongodb.com/videos/y/g7Fi1xXsuvU)
Operators
$set (modify a field)
$set lesson video (https://university.mongodb.com/videos/y/XyhNjs2pNVc)
$set documentation
(//docs.mongodb.org/manual/reference/operator/update/set/#up._S_set)
$unset (remove a field)
$unset lesson video (https://university.mongodb.com/videos/y/LpErz8jLW0I)
$unset documentation
(//docs.mongodb.org/manual/reference/operator/update/unset/#up._S_unset)
$rename
$rename documentation
(//docs.mongodb.org/manual/reference/operator/update/rename/#up._S_rename)
$setOnInsert
$setOnInsert documentation
(//docs.mongodb.org/manual/reference/operator/update/setOnInsert/#up._S_setOnInsert)
$inc
$inc documentation
(//docs.mongodb.org/manual/reference/operator/update/inc/#up._S_inc)
$mul
$mul documentation
(//docs.mongodb.org/manual/reference/operator/update/mul/#up._S_mul)
$min and $max
$min documentation
(//docs.mongodb.org/manual/reference/operator/update/min/#up._S_min)
$max documentation
(//docs.mongodb.org/manual/reference/operator/update/max/#up._S_max)
Array operators
Array operators lesson video
(https://university.mongodb.com/videos/y/GOn0EWKDQoY)
Positional $ documentation
(//docs.mongodb.org/manual/reference/operator/update/positional/#up._S_)
$addToSet documentation
(//docs.mongodb.org/manual/reference/operator/update/addToSet/#up._S_addToSet)
$pop documentation
(//docs.mongodb.org/manual/reference/operator/update/pop/#up._S_pop)
$pull documentation
(//docs.mongodb.org/manual/reference/operator/update/pull/#up._S_pull)
$pullAll documentation
(//docs.mongodb.org/manual/reference/operator/update/pullAll/#up._S_pullAll)
$push documentation
(//docs.mongodb.org/manual/reference/operator/update/push/#up._S_push)
There are additional modifiers if you use $push (and sometimes $addToSet)
$each documentation
(//docs.mongodb.org/manual/reference/operator/update/each/#up._S_each)
$slice documentation
(//docs.mongodb.org/manual/reference/operator/update/slice/#up._S_slice)
$sort documentation
(//docs.mongodb.org/manual/reference/operator/update/sort/#up._S_sort)
$position documentation
(//docs.mongodb.org/manual/reference/operator/update/position/#up._S_position)
Upserts
Upsert lesson video (https://university.mongodb.com/videos/y/Dy2p8k3EZs4)
Multi updates
Multi update lesson video (https://university.mongodb.com/videos/y/2GNNdUmDL-4)
Delete
Drop a collection
Build a query that deletes only the documents you want it to
Docs:
Video:
Sample Problems
db.stuff.update( { b : { $gte : 10 } },
{ $set : { b : 15 } },
{ multi : true, upsert : true } )
a. 0
b. 1
c. 2
d. 3
e. 5
> db.c.find()
{ "_id" : 12, b : [ 3, 5, 7, 2, 1, -4, 3, 12 ] }
Which of the following queries on the "c" collection will return only the first five elements of the array in
the "b" field? E.g.,
a. db.c.find( { } , { b : [ 0, 1, 2, 3, 4, 5 ] } )
b. db.c.find( { },{b:[0,5]})
c. db.c.find( { } , { b : { $slice : [ 0 , 5 ] } } )
d. db.c.find( { } , { b : { $substr[ 0 , 5 ] } } )
e. db.c.find( { b:[0,5]})
3. Consider the following example document from the sample collection. All documents in this collection
have the same schema.
{
"_id" : 3,
"a" : 7,
"b" : 4
}
Which of the following queries will replace this with the document,
{
"_id" : 7,
"c" : 4,
"b" : 4
}
4. Which of the documents below will be retrieved by the following query? Assume the documents are
stored in a collection called "sample". Check all that apply.
db.foo.insert( { } );
1. c
2. c
3. e
4. b, e, h, i, j
5. b
Exercises
Insert some sample data. Write a for loop that bulk inserts 1,000 documents at a time, 1000 times, for a
total of 1 million documents inserted. Do it in such a way that each of its _id fields is unique.
Perform the same operation, but use some (but not all) non-unique _id field values. See the difference
between an ordered vs. unordered bulk insert.
Perform queries on the sample set. Find documents with fields greater than certain values.
Perform updates on the sample set. Set new fields without deleting old fields, increment fields, etc.
using the update command.
Perform array operations, pushing to and popping from arrays.
Insert documents with nested subdocuments. Query on the subdocument fields.
Indexes
On the certification exam, we will verify that you:
Introduction
Videos:
Introduction to Indexes (https://university.mongodb.com/videos/y/U3iWPF5jP-g)
Docs:
Index Concepts (//docs.mongodb.org/manual/core/indexes/)
Creating Indexes
Docs:
Single Field Indexes (//docs.mongodb.org/manual/core/index-single/)
Embedded Fields (//docs.mongodb.org/manual/core/index-single/#indexes-on-embedded-fields)
Embedded Documents (//docs.mongodb.org/manual/core/index-single/#indexes-on-embedded-
documents)
Collection Scans
For the exam, you should know:
That a "collection scan" happens when every document in the collection must be checked in order to
determine the result set of a query
Whether a collection scan will occur, given a query and list of available indexes
Why a collection scan is undesirable
Videos:
Collection scans (https://university.mongodb.com/videos/y/qB6435EGS6w)
Compound Indexes
Docs:
Multikey Indexes
A multikey index is an index on an array field. The index will contain one key per array element.
Docs:
Multikey Indexes (//docs.mongodb.org/manual/core/index-multikey/)
Videos:
Multikey Indexes (video) (https://university.mongodb.com/videos/y/_NGwn_X82Dw)
Dot Notation and Multikey (https://university.mongodb.com/videos/y/wT0_ktAZbBg)
Docs:
How to create an Explainable object with db.collection.explain() and use it to explain a cursor
How to explain a cursor with cursor.explain()
The three verbosity settings of explain plans, and what they offer.
How to read each type of explain plan to determine things such as:
How many documents were returned by the query
How many documents were read by the query
How many index entries were viewed by the query
Which index was used by the query
When a collection scan occurs
How many index entries were viewed during the query
Which shards were involved in the query for a sharded collection
How to recognize that a query is covered
Whether or not an index was used to sort the query
How long the query took (or was estimated to take)
Which types of queries can use an index (.find(), .update(), .remove())
Resources:
Videos:
Explain Plans (https://university.mongodb.com/videos/y/rRsYWCO3ndY)
Using Explain (https://university.mongodb.com/videos/y/liXIn8CnJaI)
Explain Verbosity (https://university.mongodb.com/videos/y/WxXVun6bZ20)
Docs:
cursor.explain() (//docs.mongodb.org/manual/reference/method/cursor.explain/)
db.collection.explain() (//docs.mongodb.org/manual/reference/method/db.collection.explain/)
Explain Results (//docs.mongodb.org/manual/reference/explain-results/)
Selecting an Index
Covered Queries
Covered queries
Why covered queries are good for performance
How to recognize that a covered query has happened in an explain plan
Video:
Covered Queries (https://university.mongodb.com/videos/y/npFBnPAkDUk)
Docs:
Covered Query (//docs.mongodb.org/manual/core/query-optimization/#covered-query)
Indexing Strategies
How to create an index that supports a query that sorts on one field, queries for an exact match on a
second field, and does a range query on a third field
When an index can be used to sort for a particular query
How selective queries are and how much they are likely to benefit from an index
Resources:
Docs:
Indexing Strategies (//docs.mongodb.org/manual/applications/indexes/)
Optimize Query Performance (//docs.mongodb.org/manual/tutorial/optimize-query-performance-
with-indexes-and-projections/)
Indexes FAQ (//docs.mongodb.org/manual/faq/indexes/)
Query Optimization (//docs.mongodb.org/manual/core/query-optimization/)
Videos:
Efficiency of Index Use 2 (https://university.mongodb.com/videos/y/g032EW67SRA)
Index Notes (https://university.mongodb.com/videos/y/OyXFYhLXTGk)
Indexes generally speed up read performance, but can slow down write performance. Hybrid actions (e.g.,
with a find and a write) such as update and remove, may depend on the use case (though they usually are
faster with indexes).
Resources:
Docs:
Write Operation Performance (//docs.mongodb.org/manual/core/write-performance/#indexes)
Video:
Read and Write Impact of Indexes (https://university.mongodb.com/videos/y/wcprB2adSe0)
Unique Indexes
Resources:
Video:
Index Creation Options, Unique (https://university.mongodb.com/videos/y/D-Ra5TEaaL4)
Docs:
Creating a Unique Index (//docs.mongodb.org/manual/tutorial/create-a-unique-index/)
Unique Indexes (//docs.mongodb.org/manual/core/index-unique/)
Sparse Indexes
Resources:
Video:
Sparse Indexes Video (https://university.mongodb.com/videos/y/ZznHByqtTMA)
Docs:
Sparse Indexes (//docs.mongodb.org/manual/core/index-sparse/)
TTL Indexes
Video:
TTL Indexes (https://university.mongodb.com/videos/y/hu0gsu5O0Rs)
Docs:
Indexes, TTL (//docs.mongodb.org/manual/core/index-ttl/)
Resources:
Video:
Background Index Creation (https://university.mongodb.com/videos/y/rI2Hnqp8BN4)
Docs:
Build Indexes in the Background (//docs.mongodb.org/manual/tutorial/build-indexes-in-the-
background/)
Background Index Creation (//docs.mongodb.org/manual/core/index-creation/#index-creation-
background)
How standard indexes behave with strings fields (as compared to text indexes)
How to use indexes most efficiently by anchoring the regex on the left
Resources:
Text Indexes
Resources:
Video:
Text Indexes in MongoDB (https://university.mongodb.com/videos/y/UlleLqZQYVo)
Docs:
Text Indexes (//docs.mongodb.org/manual/core/index-text/)
Create a Text Index (//docs.mongodb.org/manual/tutorial/create-text-index-on-multiple-fields/)
Text Search Tutorials (//docs.mongodb.org/manual/administration/indexes-text/)
Resources:
Video:
Geospatial Indexes (https://university.mongodb.com/videos/y/zoGcMsjGMo4)
Docs:
Geospatial Indexes and Queries (//docs.mongodb.org/manual/applications/geospatial-indexes/)
2d Indexes (//docs.mongodb.org/manual/core/2d/)
Create a 2d Index (//docs.mongodb.org/manual/tutorial/build-a-2d-index/)
Query a 2d Index (//docs.mongodb.org/manual/tutorial/query-a-2d-index/)
2dsphere Indexes (//docs.mongodb.org/manual/core/2dsphere/)
Create a 2dsphere Index (//docs.mongodb.org/manual/tutorial/build-a-2dsphere-index/)
Query a 2dsphere Index (//docs.mongodb.org/manual/tutorial/query-a-2dsphere-index/)
Calculate Distance using Spherical Geometry (//docs.mongodb.org/manual/tutorial/calculate-
distances-using-spherical-geometry-with-2d-geospatial-indexes/)
Sample Problems
{
"_id": ObjectId("5360c0a0a655a60674680bbe"),
"user": {
"login": "ir0n",
"description": "Made of steel"
"date": ISODate("2014-04-30T09:16:45.836Z"),
}
}
which of the following statements correctly describe how MongoDB will handle the query? Check all that
apply.
a. As a covered query using "myIndex" because we are filtering out "_id" and only returning
"user.login"
b. As an indexed query using "myIndex" because field "user.login" is indexed
c. As an optimized sort query (scanAndOrder = false) using "myIndex" because we are sorting on an
indexed field
d. MongoDB will need to do a table/collection scan to find matching documents
e. None of the above
2. You perform the following query on the sayings collection, which has the index
{ quote : "text" }:
Assuming the documents below are in the collection, which ones will the following query return? Check
all that apply.
{
"manufacturer" : 1,
"name" : 1,
"date" : -1
}
Which of the following is able to use the index for the query? Check all that apply.
4. Adding the index { a : 1 } can potentially decrease the speed of which of the following operations?
Check all that apply.
a. db.collection.find( { a : 232 } )
b. db.collection.update( { b : 456 }, { $inc : { a : 1 } } )
c. db.collection.insert( { a : 341 } )
Which of the following queries will use the index to implicitly sort the query? Check all that apply.
a. db.things.find( { b : 1 } ).sort( { c : 1, b : 1 } )
b. db.things.find( { c : 1 } ).sort( { a : 1, b : 1 } )
c. db.things.find( { a : 1 } ).sort( { b : 1, c : 1 } )
1. b
2. a, b
3. a, b, c
4. b, c
5. a
Exercises
Create:
A single-field index
A compound index
A text index
A single-field index on a string field
A 2dsphere index
A ttl index
A unique index
A background index
For each of the above, notice how they are distinguished in db.collection.getIndexes() output.
Insert some data for the indexes you created. Perform queries for each of the indexes.
For a TTL index, write a script to insert 1 document per second. Look at when documents get deleted.
Get explain plans for these queries. Use all 3 verbosities.
Explain a covered query & verify that it's working (you'll see 0 documents viewed, though some index
entries will be viewed).
Perform some geospatial queries and look at the results.
Data Modeling
On the certification exam, we will verify that you:
Introduction
Fundamental data modeling considerations such as consideration for common data access patterns
How we define the term "working set"
Why considerations of the working set and working set size are important for efficient read and write
operations
Features used to model data in various ways, including:
GridFS
Read-only views
Collations
Special-case data types, such as NumberDecimal.
Resources:
Docs:
Data Modeling Introduction (http://docs.mongodb.org/master/core/data-modeling-introduction/)
Working Set (http://docs.mongodb.org/master/faq/diagnostics/#what-is-a-working-set)
Video:
Schema Design Introduction (https://university.mongodb.com/videos/y/AABYJM12qF4)
White Paper:
Performance Best Practices for MongoDB (https://www.mongodb.com/collateral/mongodb-
performance-best-practices?jmp=university)
Note: This is a fairly comprehensive overview, touching on many of the sections of the exam.
Document Structure
Resources:
Docs:
Document Structure (http://docs.mongodb.org/master/core/data-modeling-
introduction/#document-structure)
Data Model Design (http://docs.mongodb.org/v3.0/core/data-model-design/)
Video:
Benefits of Embedding (https://university.mongodb.com/videos/y/XIN0Dqht08Q)
When to Denormalize (https://university.mongodb.com/videos/y/jDZ-HFoJ0vg)
You don't actually need to know this, but it can help for people who come from the relational world to
know the differences.
Videos:
Living without Constraints (https://university.mongodb.com/videos/y/YFRMkDPaams)
Living without Transactions (https://university.mongodb.com/videos/y/FfRr3qjRfww)
Docs:
Database References (//docs.mongodb.org/manual/reference/database-references?
jmp=university)
Atomicity and Transactions (//docs.mongodb.org/manual/core/write-operations-atomicity?
jmp=university)
Atomicity of Write Operations (//docs.mongodb.org/manual/core/data-modeling-introduction?
jmp=university#atomicity-of-write-operations)
One-to-One Relationships
Resources:
Docs:
Model One-to-One Relationships with Embedded Documents
(http://docs.mongodb.org/master/tutorial/model-embedded-one-to-one-relationships-between-
documents/)
Video:
One to One Relationships (https://university.mongodb.com/videos/y/cCsfon0vUlQ)
One-to-Many Relationships
Resources:
Video:
One-to-Many Relationships (https://university.mongodb.com/videos/y/EIaP1KbVkUc)
Docs:
One-to-Many Relationships with Embedded Documents
(http://docs.mongodb.org/master/tutorial/model-embedded-one-to-many-relationships-between-
documents/)
One-to-Many Relationships with Document References
(http://docs.mongodb.org/master/tutorial/model-referenced-one-to-many-relationships-between-
documents/)
Blog Posts:
Rules of Thumb (http://blog.mongodb.org/post/87200945828/6-rules-of-thumb-for-mongodb-
schema-design-part-1)
Rules of Thumb Part 2 (http://blog.mongodb.org/post/87892923503/6-rules-of-thumb-for-
mongodb-schema-design-part-2)
Rules of Thumb Part 3 (http://blog.mongodb.org/post/88473035333/6-rules-of-thumb-for-
mongodb-schema-design-part-3)
Many-to-Many Relationships
Resources:
Video:
Many to Many Relationships (https://university.mongodb.com/videos/y/fEYYjZ7zEHc)
Resources:
Video:
Trees (https://university.mongodb.com/videos/y/lIjXyQklGWY)
Docs:
Model Tree Structures (http://docs.mongodb.org/master/applications/data-models-tree-
structures/)
Model Tree Structures with Parent References (http://docs.mongodb.org/master/tutorial/model-
tree-structures-with-parent-references/)
Model Tree Structures with Child References (http://docs.mongodb.org/master/tutorial/model-tree-
structures-with-child-references/)
Model Tree Structures with an Array of Ancestors (http://docs.mongodb.org/master/tutorial/model-
tree-structures-with-ancestors-array/)
Model Tree Structures with Materialized Paths (http://docs.mongodb.org/master/tutorial/model-
tree-structures-with-materialized-paths/)
Model Tree Structures with Nested Sets (http://docs.mongodb.org/master/tutorial/model-tree-
structures-with-nested-sets/)
Resources:
Docs:
Model Data to Support Keyword Search (http://docs.mongodb.org/master/tutorial/model-data-for-
keyword-search/)
Model Monetary Data (http://docs.mongodb.org/master/tutorial/model-monetary-data/)
Resources:
Video:
GridFS (https://university.mongodb.com/videos/y/AsL5p1Z0Ss8)
Docs:
GridFS Storage (//docs.mongodb.org/manual/core/gridfs/)
GridFS Reference (//docs.mongodb.org/manual/reference/gridfs/)
Views
Resources:
Video:
Views - Introduction (https://university.mongodb.com/videos/y/cNODD1GhYTY)
Creating and Destroying Views (https://university.mongodb.com/videos/y/YeijJRjq_zA)
Views, Indexes, and Views of Views (https://university.mongodb.com/videos/y/knTIfr-4Z-g)
Docs:
Views (//docs.mongodb.org/manual/core/views?jmp=university)
Resources:
Docs:
Case Insensitive Indexes (//docs.mongodb.org/manual/core/index-case-insensitive?jmp=university)
Collations (//docs.mongodb.org/manual/reference/collation?jmp=university)
Video:
Collations - Introduction (https://university.mongodb.com/videos/y/qWQbtFPZcsA)
Using collations (https://university.mongodb.com/videos/y/_Slrx_6_QjU)
Case insensitive indexes (https://university.mongodb.com/videos/y/v4e3zRbrIaA)
Collations and index selection (https://university.mongodb.com/videos/y/UtG65GUClws)
Collations on find and sort (https://university.mongodb.com/videos/y/j4FtsD7jQa0)
Collations on Indexes (https://university.mongodb.com/videos/y/oYPpgTTfXpM)
Resources:
Docs:
NumberDecimal (//docs.mongodb.org/manual/core/shell-types?jmp=university#shell-type-decimal)
Model Monetary Data (//docs.mongodb.org/manual/tutorial/model-monetary-data?jmp=university)
Video:
Decimal Type Demo (https://university.mongodb.com/videos/y/RBfkvfLRPbo)
Exercise
Aggregation
For the exam, you should understand:
Introduction
An aggregation pipeline allows you to combine data from multiple documents in a collection and perform
basic grouping, arithmetic, and statistical operations on them.
The aggregation framework in MongoDB is based on the idea of UNIX pipelining. Each stage done job. A
stage accepts a list of documents as input, manipulates the data in some way, and emits output documents,
passing them to the next stage.
The Aggregation section of the exam is emphasized much more heavily in Developer exams than in DBA
exams, but you should be familiar with the basic concepts and format of aggregation queries even for the
DBA exam.
Videos:
The Aggregation Pipeline (https://university.mongodb.com/videos/y/AuO8CEkTG6Y)
Docs:
Aggregation Introduction (//docs.mongodb.org/manual/aggregation?jmp=university)
Aggregation Pipeline (//docs.mongodb.org/manual/core/aggregation-pipeline?jmp=university)
Aggregation Expressions
Resources:
Videos:
Aggregation Expressions (https://university.mongodb.com/videos/y/x8hl0bfJ_mk)
Docs
Expressions Reference (//docs.mongodb.org/manual/meta/aggregation-quick-reference?
jmp=university#expressions)
Aggregation Stages
Resources:
Videos:
Using $project (https://university.mongodb.com/videos/y/TbQ2PI5Fib0)
Using $match (https://university.mongodb.com/videos/y/7RtHG90Hrbw)
Using $text (https://university.mongodb.com/videos/y/LpDSge_GbpI)
Using $sort (https://university.mongodb.com/videos/y/HUEtV7omSb8)
Using $limit and $skip (https://university.mongodb.com/videos/y/o5hzYKXUyrU)
Using $unwind (https://university.mongodb.com/videos/y/E4aYOQPeQvI)
Using $out (https://university.mongodb.com/videos/y/b1dfUSrTPto)
Introduction to $graphLookup (https://university.mongodb.com/videos/y/ekNzU0etEMM)
Example of $graphLookup (https://university.mongodb.com/videos/y/weJ4eyIKabM)
$count, $replaceRoot, $addFields (https://university.mongodb.com/videos/y/f0rs9-yCQwg)
Docs:
Aggregation Pipeline Quick Reference (//docs.mongodb.org/manual/meta/aggregation-quick-
reference?jmp=university)
$collStats (//docs.mongodb.org/manual/reference/operator/aggregation/collStats?jmp=university)
$project (//docs.mongodb.org/manual/reference/operator/aggregation/project?jmp=university)
$match (//docs.mongodb.org/manual/reference/operator/aggregation/match?jmp=university)
$redact (//docs.mongodb.org/manual/reference/operator/aggregation/redact?jmp=university)
$limit (//docs.mongodb.org/manual/reference/operator/aggregation/limit?jmp=university)
$skip (//docs.mongodb.org/manual/reference/operator/aggregation/skip?jmp=university)
$unwind (//docs.mongodb.org/manual/reference/operator/aggregation/unwind?jmp=university)
$group (//docs.mongodb.org/manual/reference/operator/aggregation/group?jmp=university)
$sample (//docs.mongodb.org/manual/reference/operator/aggregation/sample?jmp=university)
$sort (//docs.mongodb.org/manual/reference/operator/aggregation/sort?jmp=university)
$geoNear (//docs.mongodb.org/manual/reference/operator/aggregation/geoNear?jmp=university)
$lookup (//docs.mongodb.org/manual/reference/operator/aggregation/lookup?jmp=university)
$out (//docs.mongodb.org/manual/reference/operator/aggregation/out?jmp=university)
$indexStats (//docs.mongodb.org/manual/reference/operator/aggregation/indexStats?
jmp=university)
$facet (//docs.mongodb.org/manual/reference/operator/aggregation/facet?jmp=university)
$bucket (//docs.mongodb.org/manual/reference/operator/aggregation/bucket?jmp=university)
Aggregation Operators
Resources:
Videos:
Using $sum (https://university.mongodb.com/videos/y/93MSz3uDC1A)
Using $avg (https://university.mongodb.com/videos/y/baIDZ-M5j7w)
Using $addToSet (https://university.mongodb.com/videos/y/YzURaZnKI9s)
Using $push (https://university.mongodb.com/videos/y/LQcBM-g0ACY)
Using $max and $min (https://university.mongodb.com/videos/y/BYoNX4trjOQ)
Double $group Stages (https://university.mongodb.com/videos/y/EIWF9Oxeb8M)
Revisiting $first and $last (https://university.mongodb.com/videos/y/JOdAnxVAMwc)
Docs:
$match (//docs.mongodb.org/manual/reference/operator/aggregation/match?
jmp=university#pipe._S_match)
$group (//docs.mongodb.org/manual/reference/operator/aggregation/group?
jmp=university#pipe._S_group)
$project (//docs.mongodb.org/manual/reference/operator/aggregation/project?jmp=university)
Aggregation Pipeline Operators (//docs.mongodb.org/manual/reference/operator/aggregation?
jmp=university)
Aggregation Mechanics
Memory limits imposed on the aggregation pipeline's data, and for use in sorting
Optimizations that are applied to the aggregation pipeline
When you are able to use indexes for aggregation
Resources:
Video:
Aggregation Limits (https://university.mongodb.com/videos/y/U_gRSxEq3c0)
Docs:
Optimizing the Aggregation Pipeline (//docs.mongodb.org/manual/core/aggregation-pipeline-
optimization?jmp=university)
Aggregation Limits (//docs.mongodb.org/manual/core/aggregation-pipeline-limits?jmp=university)
Aggregation Pipeline Behavior (//docs.mongodb.org/manual/core/aggregation-pipeline?
jmp=university#aggregation-pipeline-behavior)
Aggregation Options
Resources:
Docs:
db.collection.aggregate() (//docs.mongodb.org/manual/reference/method/db.collection.aggregate?
jmp=university)
Video:
Aggregation Options (https://university.mongodb.com/videos/y/0CGNVacCrY8)
Aggregation Examples
More than any other section, Aggregation is about practice. Here are some examples to give you some ideas
and help you to get started.
How to construct an aggregation query that will perform the operations you require
How to use multiple $group and $unwind stages to accomplish more than you could without them
Resources:
Videos:
Simple Aggregation Example (https://university.mongodb.com/videos/y/DQBXCsjeO5c)
Simple Aggregation Expanded (https://university.mongodb.com/videos/y/3lEpnMcfpCs)
$unwind Example (https://university.mongodb.com/videos/y/U_4Enh2TTp4)
Compound Grouping (https://university.mongodb.com/videos/y/qTbtax_cKcc)
Double Unwind (https://university.mongodb.com/videos/y/YXGL27217B8)
Docs:
Single Purpose Aggregation Operations (//docs.mongodb.org/manual/core/single-purpose-
aggregation?jmp=university)
Aggregation with Zip Code Data (//docs.mongodb.org/manual/tutorial/aggregation-zip-code-data-
set?jmp=university)
Aggregation with User Preference Data (//docs.mongodb.org/manual/tutorial/aggregation-with-
user-preference-data?jmp=university)
1. Which of the following statements are true about the $match pipeline operator? Check all that apply.
> db.people.find()
{ "_id" : "apples", "traits" : [ "sweet" , "crispy" ] }
{ "_id" : "oranges", "traits" : [ "sweet" , "orange" , "juicy" ] }
If you run an aggregation query and use { $unwind : "$traits" } as the first stage, how many documents
will be passed to the next stage of the aggregation pipeline?
1
2
3
4
5
Answers
1. a, b, c
2. 5
Find or build a data set. Perform an aggregation query to see how many documents contain a field
within a given range.
Count all of the elements in an array field, summed across all documents in the collection.
Count only the elements in an array field above a certain value.
Count the elements in an array field, but only for documents where another field has a certain value.
Replication
On the certification exam, we will attempt to verify that you:
Introduction
Replication is about availability and durability. It is, generally speaking, not for scaling. That would be the
purpose of Sharding.
Videos:
Replication Concepts (https://university.mongodb.com/videos/y/AYBOd-tpdKo)
Replication Overview (https://university.mongodb.com/videos/y/eNFWxRFIbcI)
Asynchronous Replication (https://university.mongodb.com/videos/y/3p30vjb-Rx8)
Docs:
Replication Introduction (//docs.mongodb.org/manual/core/replication-introduction/)
Nodes
Resources:
Docs:
Replica Set Members (//docs.mongodb.org/manual/core/replica-set-members/)
Delayed Members (//docs.mongodb.org/manual/core/replica-set-delayed-member/)
Hidden Members (//docs.mongodb.org/manual/core/replica-set-hidden-member/)
Non-Voting Members (//docs.mongodb.org/manual/tutorial/configure-a-non-voting-replica-set-
member/)
Videos:
Arbiters (https://university.mongodb.com/videos/y/4W0GO2CAu2w)
Hidden and Slave Delay (https://university.mongodb.com/videos/y/X1hCBT2UTuo)
How to initiate a replica set (or initiate a single server and add members)
The initial sync of a secondary
Video:
Initiating a Replica Set (https://university.mongodb.com/videos/y/EaGhuXPZZbk)
Docs:
rs.initiate() (//docs.mongodb.org/manual/reference/method/rs.initiate/#rs.initiate)
Initial Sync (//docs.mongodb.org/manual/core/replica-set-sync/#initial-sync)
Elections
Resources:
Docs:
Elections (//docs.mongodb.org/manual/core/replica-set-elections/)
Non-voting members (//docs.mongodb.org/manual/tutorial/configure-a-non-voting-replica-set-
member/)
Failover
Resources:
Video:
Automatic Failover (https://university.mongodb.com/videos/y/VsnI8uCTG60)
Failover Example (https://university.mongodb.com/videos/y/MGoHhWbMDaU)
Docs:
Replica Set High Availability (//docs.mongodb.org/manual/core/replica-set-high-availability/)
Rollback
Resources:
Video:
Recovery (https://university.mongodb.com/videos/y/TGsnu9RBjzA)
Docs:
Rollbacks (//docs.mongodb.org/manual/core/replica-set-rollbacks/)
rs.status()
Resources:
Video:
Replica Set Status (https://university.mongodb.com/videos/y/QspOQbOShSY)
Docs:
rs.status() Example (//docs.mongodb.org/manual/reference/command/replSetGetStatus/#example)
Resources:
Docs:
rs.add() (//docs.mongodb.org/manual/reference/method/rs.add/)
rs.remove() (//docs.mongodb.org/manual/reference/method/rs.remove/)
rs.reconfig() (//docs.mongodb.org/manual/reference/method/rs.reconfig/)
Reconfigure a Replica Set (//docs.mongodb.org/manual/tutorial/reconfigure-replica-set-with-
unavailable-members/)
Oplog
Resources:
Video:
Statement Based vs Binary Replication (https://university.mongodb.com/videos/y/yutpUgJMkk4)
Docs
Replica Set Oplog (//docs.mongodb.org/manual/core/replica-set-oplog/)
Capped Collections (//docs.mongodb.org/manual/core/capped-collections/)
Idempotent (glossary) (//docs.mongodb.org/manual/reference/glossary/#term-idempotent)
Read Preference
Which server (or servers) could be queried for every possible read concern (depending on the state of
your servers, as well)
When your read preference allows you to read stale data
Resources:
Docs:
Read Preference Reference (//docs.mongodb.org/manual/reference/read-preference/)
Videos:
Introduction to Read Preference (https://university.mongodb.com/videos/y/I62q4cyeSyc)
Read Preference Options (https://university.mongodb.com/videos/y/jCEZvexlpj4)
Write Concern
Resources:
Videos:
Write Concern Principles (https://university.mongodb.com/videos/y/73Jl2woKhNo)
Examining the 'w' parameter (https://university.mongodb.com/videos/y/K3N6psPZCD0)
Write Concern Use Cases and Patterns (https://university.mongodb.com/videos/y/sSkFhx1jKSs)
Docs:
Write Concern (//docs.mongodb.org/manual/core/write-concern/)
Write Concern Reference (//docs.mongodb.org/manual/reference/write-concern/)
Sample Problems
1. Given a replica set with five data-bearing members, suppose the primary goes down with operations in
its oplog that have been copied from the primary to only one secondary. Assuming no other problems
occur, which of the following describes what is most likely to happen?
a. The primary may roll back the operations once it recovers.
b. The secondary with the most current oplog will be elected primary.
c. Missing operations will need to be manually re-performed.
d. The most current secondary will roll back the operations following the election.
e. Reads will be stale until the primary comes back up.
2. Which of the following is true of the mechanics of replication in MongoDB? Check all that apply.
a. Operations on the primary are recorded in a capped collection called the oplog.
b. Members of a replica set may replicate data from any other data-bearing member of the set by
default.
c. Clients read from the nearest member of a replica set by default.
3. What read preference should your application use if you want to read from the primary under normal
circumstances but allow reads from secondaries when a primary is unavailable?
a. Nearest
b. primary
c. primaryPreferred
d. secondaryPreferred
e. Secondary
4. Using an arbiter allows one to easily ensure an odd number of voters in replica sets. Why is this
important?
a. To add greater redundancy
b. For more efficient backup operations
c. To help in disaster recovery
d. To protect against network partitions
e. To enable certain read preference settings
1. b
2. a, b
3. c
4. d
Sharding
On the certification exam, we will verify that you:
Understand horizontal scaling and how sharding provides this capability in MongoDB
Know how to construct a good shard key, and what can go wrong with selecting a shard key
Understand the balancer
Know the role of the config servers and how they work.
Introduction
Sharding is about scaling. With sharding, you can distribute your data across several replica sets, each of
which is a logical "node" in the sharded cluster.
Note that sharding and replication solve different problems. Replication is concerned with data durability and
high availability.
Resources:
Docs:
Sharding Introduction (//docs.mongodb.org/manual/sharding?jmp=university)
Sharded Cluster Components (//docs.mongodb.org/manual/core/sharded-cluster-components?
jmp=university)
Shards (//docs.mongodb.org/manual/core/sharded-cluster-shards?jmp=university)
Video:
Introduction to Sharding (https://youtu.be/_GfDqa1qRl0?t=35s)
Sharding and Data Distribution (https://university.mongodb.com/videos/y/xvWzS9j7IIY)
Resources:
Docs:
Shard Keys (//docs.mongodb.org/manual/core/sharding-shard-key?jmp=university)
Shard Key Indexes (//docs.mongodb.org/manual/core/sharding-shard-key-indexes?
jmp=university#shard-key-indexes)
Unique Keys (https://docs.mongodb.com/v3.0/tutorial/enforce-unique-keys-for-sharded-
collections?jmp=university)
Resources:
Docs:
Chunk (glossary entry) (//docs.mongodb.org/manual/reference/glossary?jmp=university#term-
chunk)
Chunk Splits in a Sharded Cluster (//docs.mongodb.org/manual/core/sharding-chunk-splitting?
jmp=university)
Sharded Collection Balancing (//docs.mongodb.org/manual/core/sharding-balancing?
jmp=university)
Videos:
Chunks and Operations (https://university.mongodb.com/videos/y/v7Gibss9JAk)
Resources:
Docs:
Config Servers (//docs.mongodb.org/manual/core/sharded-cluster-config-servers?jmp=university)
Replica Set Config Servers (//docs.mongodb.org/manual/core/sharded-cluster-config-servers?
jmp=university#replica-set-config-servers)
Config Server Availability (//docs.mongodb.org/manual/core/sharded-cluster-config-servers?
jmp=university#config-server-availability)
Sharded Cluster Metadata (//docs.mongodb.org/manual/core/sharded-cluster-config-servers?
jmp=university#sharded-cluster-metadata)
Videos:
Config DB (https://university.mongodb.com/videos/y/WVXmIVUGBm4)
Cluster Setup Topology (https://university.mongodb.com/videos/y/ZyDNnN8-4Ak)
Sharding Processes (https://university.mongodb.com/videos/y/XMnxjcdiMJs)
Resources:
Docs:
Create Chunks (//docs.mongodb.org/manual/tutorial/create-chunks-in-sharded-cluster?
jmp=university)
Split Chunks (//docs.mongodb.org/manual/tutorial/split-chunks-in-sharded-cluster?jmp=university)
Resources:
Docs:
Broadcast Operations (//docs.mongodb.org/manual/core/sharded-cluster-query-router?
jmp=university#broadcast-operations)
Targeted Operations (//docs.mongodb.org/manual/core/sharded-cluster-query-router?
jmp=university#targeted-operations)
Sharded Cluster Query Routing (//docs.mongodb.org/manual/core/sharded-cluster-query-router?
jmp=university)
Aggregation Pipeline and Sharded Collections (//docs.mongodb.org/manual/core/aggregation-
pipeline-sharded-collections?jmp=university)
Video:
Implications of Sharding (https://university.mongodb.com/videos/y/ig278F60gRA)
Resources:
Docs:
Choose a Shard Key (//docs.mongodb.org/manual/tutorial/choose-a-shard-key?jmp=university)
Shard a Collection using a Hashed Shard Key (//docs.mongodb.org/manual/tutorial/shard-
collection-with-a-hashed-shard-key?jmp=university)
Video:
Choosing a Shard Key (https://university.mongodb.com/videos/y/8q2GB3QSBSI)
Shard Key Selection Example (https://university.mongodb.com/videos/y/ujlNVJK5dMc)
Primary Shard
Resources:
Docs:
Primary shard (//docs.mongodb.org/manual/core/sharded-cluster-shards?jmp=university#primary-
shard)
Exercises
Introduction
While the definitions are somewhat fluid, Application Administration deals with MongoDB's relationship to
applications. The features we consider here include: the wire protocol, over-the-wire encryption, and security.
Journal
Resources:
Videos:
Journal's impact on resident memory (https://university.mongodb.com/videos/y/8TmmEzm50cw)
Docs:
Journaling Mechanics (//docs.mongodb.org/manual/core/journaling/)
Manage Journaling (//docs.mongodb.org/manual/tutorial/manage-journaling/)
Blog:
How MongoDB's Journaling Works (http://blog.mongodb.org/post/33700094220/how-mongodbs-
journaling-works)
Server Logs
The Profiler
Resources:
Docs:
Database Profiling (//docs.mongodb.org/manual/administration/analyzing-mongodb-
performance/#database-profiling)
Videos:
Profiler Demo (https://university.mongodb.com/videos/y/_ApSNwSRYVo)
Profiling Overview (https://university.mongodb.com/videos/y/ww5pYJqukAg)
Profiler Helper Function (https://university.mongodb.com/videos/y/_ApSNwSRYVo)
Examining Profiler Operations (https://university.mongodb.com/videos/y/FSrJz_hkisM)
Filtering the Profiler by Timestamp (https://university.mongodb.com/videos/y/P6igqf5Vc9w)
Resources:
MongoDB Security
How to define user roles and permissions in MongoDB Challenge and Response (MongoDB-CR)
Which other security best practices are available
Resources:
Docs:
Security Introduction (//docs.mongodb.org/manual/core/security-introduction/)
Authentication (//docs.mongodb.org/manual/core/authentication/)
Authorization (//docs.mongodb.org/manual/core/authorization/)
Hardening Network Infrastructure (//docs.mongodb.org/manual/core/security-network/)
Collection-Level Access Control (//docs.mongodb.org/manual/core/collection-level-access-
control/)
Auditing (//docs.mongodb.org/manual/core/auditing/)
Security Tutorials (//docs.mongodb.org/manual/administration/security/)
Cluster Architecture
For the exam, you should know common deployment patterns for:
Replica sets
Sharded clusters
Resources:
Basic commands to look at server, replica set, and sharded cluster status
How to interpret those commands
Solutions to simple problems that may arise, such as:
A server is down
A config server is down
A long-running query is grabbing too many resources
All queries are confined to one server in a sharded cluster
Resources:
Docs:
db.currentOp() (//docs.mongodb.org/manual/reference/method/db.currentOp/)
db.serverStatus() (//docs.mongodb.org/manual/reference/method/db.serverStatus/)
Diagnostics (//docs.mongodb.org/manual/faq/diagnostics/)
rs.status() (//docs.mongodb.org/manual/reference/method/rs.status/)
sh.status() (//docs.mongodb.org/manual/reference/method/sh.status/)
db.killOp() (//docs.mongodb.org/manual/reference/method/db.killOp/)
Webinar:
Diagnostics and Debugging (https://www.mongodb.com/presentations/webinar-diagnostics-and-
debugging-mongodb)
Maintenance
Resources:
Docs:
Rotate Log Files (http://docs.mongodb.org/v2.6/tutorial/rotate-log-files/)
Upgrade to the Latest Version of MongoDB (http://docs.mongodb.org/v2.6/tutorial/upgrade-
revision/)
Videos:
Removing a Shard (https://university.mongodb.com/videos/y/kSlGXXe215Q)
Upgrading a Sharded Cluster (https://university.mongodb.com/videos/y/3XrnQ9yFwfU)
Resources:
Docs:
Backup and Restore with Filesystem Snapshots (//docs.mongodb.org/manual/tutorial/backup-
with-filesystem-snapshots/)
Restore a Replica Set from MongoDB Backups (//docs.mongodb.org/manual/tutorial/restore-
replica-set-from-backup/)
Backup and Restore with MongoDB Tools (http://docs.mongodb.org/v2.6/tutorial/backup-with-
mongodump/)
Videos:
Overview of Backing Up (https://university.mongodb.com/videos/y/hl58MKd2jCs)
Mongodump (https://university.mongodb.com/videos/y/tbQE2ZPPbHA)
Filesystem Snapshot (https://university.mongodb.com/videos/y/6A_jy8_YRIg)
Backing Up a Sharded Cluster (https://university.mongodb.com/videos/y/DAWoj5Hd2Mo)
Backup Strategies (https://university.mongodb.com/videos/y/7x9UPaq-i78)
Introduction
Most of the information tested can be found by running the tools with the --help option.
mongoimport
mongoexport
mongostat
mongotop
mongoimport
mongoexport
mongostat
mongotop
mongodump
mongorestore
mongosniff
mongofiles
bsondump
mongoperf
For the exam, you should know how to import/export data between MongoDB and:
JSON files
CSV files
Resources:
Docs:
mongoimport docs (https://docs.mongodb.org/v3.0/reference/program/mongoimport/)
mongoexport docs (https://docs.mongodb.org/v3.0/reference/program/mongoexport/)
mongostat docs (https://docs.mongodb.org/v3.0/reference/program/mongostat/)
mongotop docs (https://docs.mongodb.org/v3.0/reference/program/mongotop/)
Videos:
Importing from Reddit (https://university.mongodb.com/videos/y/oVmoi6fS4X8)
How to use mongostat to monitor MongoDB for both the MMAPv1 and WiredTiger storage engines
How to use mongotop to look at server activity
What fields are of particular interest when diagnosing certain types of performance problems in both
mongostat and mongotop
Resources:
Docs:
mongostat (//docs.mongodb.org/manual/reference/program/mongostat/)
mongotop (//docs.mongodb.org/manual/reference/program/mongotop/)
Videos:
mongostat video (https://university.mongodb.com/videos/y/E2aDTSes3Wc)
mongotop video (https://university.mongodb.com/videos/y/D9YLXgy7NYo)
Resources:
Docs:
mongodump (//docs.mongodb.org/manual/reference/program/mongodump/)
mongorestore (//docs.mongodb.org/manual/reference/program/mongorestore/)
For the exam, you should know how to use the following tools:
mongosniff
bsondump
mongoperf
Resources:
Docs:
mongosniff (//docs.mongodb.org/manual/reference/program/mongosniff/)
bsondump (//docs.mongodb.org/manual/reference/program/bsondump/)
mongoperf (//docs.mongodb.org/manual/reference/program/mongoperf/)
For the exam, you will need to be able to use mongofiles to put data into GridFS.
Resources:
mongofiles (//docs.mongodb.org/manual/reference/program/mongofiles/)
For each of the server tools listed above, run the tool with --help.
Run mongostat.
Write a little code that bulk inserts 1,000 small documents per batch as fast as possible for at least
a minute.
Run the code and look at the output of mongostat, and compare it with your expectations. Pay
attention to each field.
Run mongostat.
Then, write a little code that individually inserts one large document (100+ kb per insert) at a time
as fast as possible for at least a minute.
Run it and look at the output of mongostat, comparing the output with your expectations.
Pay attention to each field. This time, try to use a different storage engine than you did last time.
Run mongotop.
Using a script from either mongostat exercise, begin inserting data, and also run some queries in
another database.
Look at the output of mongotop.
For mongoperf, run a similar experiment as you did for mongotop.
Import a JSON file into a MongoDB collection. You might find one at Reddit's technology subreddit, the
Enron email data set, or find something else on the web.
Technology Subreddit (https://www.reddit.com/r/technology/.json)
Enron email data set (http://www.cs.cmu.edu/~enron/)
You may find that the format isn't quite what you want. Transform it, either with a script or with the
aggregation pipeline, using $out, into a more usable form.
Find a CSV data set from US public data, and import it. If you don't like its initial format, you can
transform it and put it in a new collection using the aggregation pipeline's $out function.
US public data (https://catalog.data.gov/dataset?res_format=CSV)
Perform a mongodump.
Look at the output using bsondump.
Drop the database and then use mongorestore to get it back from your backup.
Run a mongodump with the --oplog option and compare the mongorestore with the --oplog replay
option and without.
If you are running a Linux machine, run mongosniff and run some queries; find them using mongosniff.
Storage Engines
For the exam, we will verify that you know:
Introduction
A database storage engine is the underlying software component that a database management system uses
to create, read, update, and delete data from a database. In the case of MongoDB, the storage engine
organizes BSON data in memory and on disk to support read and write operations. Pluggable storage
engines were introduced with MongoDB 3.0. Prior to that, MongoDB's storage engine was what we now call
MMAPv1.
Docs:
MMAPv1 (//docs.mongodb.org/manual/core/mmapv1?jmp=university)
WiredTiger (//docs.mongodb.org/manual/core/wiredtiger?jmp=university)
Videos:
Storage Engines Introduction (https://university.mongodb.com/videos/y/yV8qgeXvAyI)
Locks/Concurrency
MMAPv1 uses collection level locking in MongoDB 3.0
WiredTiger supports document-level concurrency
Journaling
Journaling is recommended for both MMAPv1 and WiredTiger
For MMAPv1, it ensures that writes are atomic
For WT, it ensures that writes make it to disk between checkpoints
Data Compression
WiredTiger supports both the snappy and zlib compression algorithms
MMAPv1 does not support data compression
Other Considerations
Due to the way MMAPv1 organizes data, if a BSON document outgrows its allotted space, it must
be moved. Indexes that point to this document point to its file offset and will need to be updated.
As a consequence, writes that force a document to move on disk come at a relatively high
performance cost. Document movement also leads to fragmentation.
To minimize document movement, MMAPv1 uses a power-of-two size allocation strategy,
allocating a "record space" to each document that is larger than the document. If the document
outgrows its record space, the newly allocated space for the document will be twice as large as
the previous allocation. Power-of-two sizing also enables the storage engine to more easily reuse
space vacated by a moved document, because all document allocations will be a size that is a
power of two.
MMAPv1
WiredTiger
Whether a dbpath directory is for MMAPv1 or WiredTiger based on the files present
For MMAPv1, the maximum size of database files and when MMAPv1 will create new database files
$ ls -la
total 1179664
-rw------- 1 will staff 16M Sep 14 08:56 test.ns
-rw------- 1 will staff 64M Sep 14 08:56 test.0
-rw-r--r-- 1 will staff 69B Sep 10 15:52 storage.bson
-rwxr-xr-x 1 will staff 5B Sep 10 15:52 mongod.lock*
-rw------- 1 will staff 16M Sep 16 00:38 local.ns
-rw------- 1 will staff 256M Sep 16 00:38 local.1
-rw------- 1 will staff 64M Sep 10 15:54 local.0
drwxr-xr-x 4 will staff 136B Sep 14 08:55 journal/
-rw------- 1 will staff 16M Sep 16 00:38 foo.ns
-rw------- 1 will staff 64M Sep 16 00:38 foo.0
drwxr-xr-x 2 will staff 68B Sep 16 00:34 _tmp/
drwxr-xr-x 4 will staff 136B Sep 10 15:52 ../
drwxr-xr-x 15 will staff 510B Sep 16 00:34 ./
$ ls -la
total 360
-rw-r--r-- 1 will staff 95B Sep 16 15:43 storage.bson
-rw-r--r-- 1 will staff 16K Sep 16 15:43 sizeStorer.wt
-rwxr-xr-x 1 will staff 6B Sep 16 15:43 mongod.lock*
drwxr-xr-x 5 will staff 170B Sep 16 15:43 journal/
-rw-r--r-- 1 will staff 16K Sep 16 15:43 index-5-5307542050812875631.wt
-rw-r--r-- 1 will staff 16K Sep 16 15:43 index-3-5307542050812875631.wt
-rw-r--r-- 1 will staff 16K Sep 16 15:43 index-1-5307542050812875631.wt
drwxr-xr-x 4 will staff 136B Sep 16 15:43 diagnostic.data/
-rw-r--r-- 1 will staff 4.0K Sep 16 15:43 collection-6-5307542050812875631.wt
-rw-r--r-- 1 will staff 16K Sep 16 15:43 collection-4-5307542050812875631.wt
-rw-r--r-- 1 will staff 16K Sep 16 15:43 collection-2-5307542050812875631.wt
-rw-r--r-- 1 will staff 16K Sep 16 15:43 collection-0-5307542050812875631.wt
-rw-r--r-- 1 will staff 16K Sep 16 15:43 _mdb_catalog.wt
-rw-r--r-- 1 will staff 4.0K Sep 16 15:43 WiredTigerLAS.wt
-rw-r--r-- 1 will staff 24K Sep 16 15:43 WiredTiger.wt
-rw-r--r-- 1 will staff 907B Sep 16 15:43 WiredTiger.turtle
-rw-r--r-- 1 will staff 21B Sep 16 15:43 WiredTiger.lock
-rw-r--r-- 1 will staff 45B Sep 16 15:43 WiredTiger
drwxr-xr-x 4 will staff 136B Sep 16 15:43 ../
drwxr-xr-x 20 will staff 680B Sep 16 15:43 ./
Contact
(https://twitter.com/mongodb)
Us (/contact) (http://www.youtube.com/user/MongoDB)
Help (/help)
(https://www.facebook.com/mongodb) (http://www.linkedin.com/company/mongodbinc)