MongoDB University - PreExamDBA2
MongoDB University - PreExamDBA2
Exam Overview
CRUD 3 2 5
Indexes 8 3 11
Server Administration 9 2 11
Application Administration 3 7 10
Replication 8 2 10
Sharding 6 4 10
Question 1
Question 2
Question 3
COPY
use services
db.restaurants.aggregate([
{
"$sort" : {"rating" : -1}
},
{
"$match": {
"reviews": { "$gte": 5 }
}
}
])
the sort order will be reversed to the direction of the shard key
Detailed Answer
The optimizer will re-order the match stage to before the sort.
CRUD
Question 1
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 2/32
28/10/2019 MongoDB University
Question 2
{
"loan_amount_USD": NumberDecimal(2000),
"due_date": "01-30-2023",
"guarantor": false
}
{
"loan_amount_USD": NumberDecimal(10000),
"due_date": "01-30-2027",
"guarantor": true
}
{
"loan_amount_USD": NumberDecimal(1000),
"due_date": "01-30-2023",
}
Detailed Answer
Correct Answers
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 3/32
28/10/2019 MongoDB University
COPY
{
"loan_amount_USD": NumberDecimal(10000),
"due_date": "01-30-2027",
"guarantor": true
}
COPY
{
"loan_amount_USD": NumberDecimal(2000),
"due_date": "01-30-2023",
"guarantor": false
}
Both of these documents contain the guarantor field, so they would both be
returned by this query.
Incorrect Answer
COPY
{
"loan_amount_USD": NumberDecimal(1000),
"due_date": "01-30-2023",
}
This document does not contain the guarantor field, so it would not be
returned by this query.
Question 3
Detailed Answer
Incorrect Answer:
Correct Answers:
$geoWithin
Question 4
Question 5
Indexes
Question 1
Question 2
Question 3
Question 4
COPY
db.animals.find(
{},
{ "_id": 0, "species": 1, "name": 1,
"number_of_chromosomes": 1 }
).sort(
{ "number_of_chromosomes": -1 }
)
{ "number_of_chromosomes": 1 } COPY
Detailed Answer
Correct answer:
This is because when we are sorting with a single field index, we can always sort
our documents either in ascending or descending order regardless of the
physical ordering of the index keys.
Question 5
{ climate: 1 } COPY
Detailed Answer
Correct Answers:
These queries can use the index, because the query selector filters on
the "climate" field.
Incorrect Answer:
These queries can NOT use the index, because the query selector
does not filter on the "climate" field.
Question 6
Question 7
Question 8
Question 9
allPlansExecution
executionStats
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 8/32
28/10/2019 MongoDB University
queryPlanner
Detailed Answer
query would have used an index without impacting other operations more heavily.
Question 10
Question 11
Server Administration
Question 1
Consider a write operation that takes 150 milliseconds, and a database profiler
that uses the default value of slowms.
Which of the following profiler levels would cause the profiler to capture this
operation?
2
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 9/32
28/10/2019 MongoDB University
Detailed Answer
Correct Answers
This profiling level will record all operations that exceed the slowms
limit, which is 100ms by default.
This profiling level will record all operations, regardless of how long
they take.
Incorrect Answers
Question 2
Question 3
COPY
Detailed Answer
Level is INFORMATIONAL
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 11/32
28/10/2019 MongoDB University
Question 4
Question 5
Question 6
Question 7
Question 8
Question 9
Question 10
Question 11
Application Administration
Question 1
COPY
db.createUser({
"user": "appusername",
"pwd": "apppassword",
"roles": [ { "role": "readWrite", "db":
"applicationDB" } ]
})
Assume that the audit log captured this operation. By default, what information
will appear in the audit log?
Detailed Answer
Correct Answers
Incorrect Answers
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 13/32
28/10/2019 MongoDB University
Question 2
use test
db.createCollection("games")
use test
db.dropCollection("games")
use production
db.createCollection("test")
Detailed Answer
Correct Option:
COPY
use test
db.createCollection("games")
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 14/32
28/10/2019 MongoDB University
This instruction will be logged in the audit log because both the audit namespace
is test.games and the action type createCollection are defined in the
auditFilter.
Incorrect Options:
COPY
use production
db.createCollection("test")
COPY
use test
db.dropCollection("games")
In this case both the action dropCollection and the namespace test.games
are part of the audit filter. However, given the information that we have, we
cannot guarantee that the collection games exists in the test database,
therefore we cannot be sure that this command will be successful. The audit log
will only log successful operations, operations that complete. Given that we are
looking for operations that must be logged, we cannot tell for sure that this
would be a successful operation.
Question 3
When creating a database user in the $external database, using the subject
line of a X.509 certificate, what password should you use?
$external
x509
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 15/32
28/10/2019 MongoDB University
No password
Detailed Answer
The correct answer is "No password". This is because the user created in the
$external database must exactly match the subject line in the presented
certificate, and the presented certificate must be signed by the same Certificate
Authority (CA) that signed the certificate used by the server.
Question 4
Question 5
COPY
{
"_id" : "admin.matt",
"user" : "matt",
"db" : "admin",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
],
"mechanisms" : [
"SCRAM-SHA-1",
"SCRAM-SHA-256"
]
}
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 16/32
28/10/2019 MongoDB University
Which commands would let you see the privileges and actions for this user?
db.getRole( "userAdminAnyDatabase" )
Detailed Answer
Correct Options:
This is the most straightforward way to see the privileges and actions this user
can execute.
This command would give you more than you need, listing all the privileges for all
roles, however since our user has only one role, it is possible to locate that
section in the output to see the list of privileges and actions that are allowed.
Incorrect Options:
db.getRole( "userAdminAnyDatabase" )
This command would provide the desired information if you add the option
{"showPrivileges": true} to it. Otherwise, the information returned is much
less detailed.
Question 6
COPY
use admin
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 17/32
28/10/2019 MongoDB University
use admin
db.createRole(
{
"role": "intern",
"privileges": [
{ "resource": { "db": "", "collections": "" },
"actions": [ "find", "createIndex" ] }
],
"roles": []
}
)
Which of the following are commands that this user-defined role is authorized to
execute?
db.customers.createIndex({"username": 1 })
db.products.find({"name": {"$exists": 1} })
Detailed Answer
Correct Options:
db.products.find({"name": {"$exists": 1} })
db.customers.createIndex({"username": 1 })
Both these operations will be allowed by the intern role given that this role
allows for find and createIndex actions in all collections and in all
collections.
Question 7
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 18/32
28/10/2019 MongoDB University
Question 8
COPY
db.getRole('readWriteAndDbAdmin')
{
"role": "readWriteAndDbAdmin",
"db": "products",
"isBuiltin": false,
"roles": [
{
"role": "readWrite",
"db": "products"
}
],
"inheritedRoles": [
{
"role": "readWrite",
"db": "products"
}
]
}
You are requested to grant new set of privileges to this role, so you run the
following command:
COPY
db.grantRolesToRole(
"readWriteAndDbAdmin",
[ { "role": "dbAdmin", "db": "products" } ]
)
To check that the role now contains the expected privileges you run this
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 19/32
28/10/2019 MongoDB University
To check that the role now contains the expected privileges, you run this
command:
db.getRole("readWriteAndDbAdmin") COPY
{
"role": "readWriteAndDbAdmin",
"db": "products",
"isBuiltin": false,
"roles": [
{
"role": "readWrite",
"db": "products"
},
{
"role": "dbAdmin",
"db": "products"
}
],
"inheritedRoles": [
{
"role": "dbAdmin",
"db": "products"
},
{
"role": "readWrite",
"db": "products"
}
]
}
{
"role": "readWriteAndDbAdmin",
"db": "products",
"isBuiltin": false,
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 20/32
28/10/2019 MongoDB University
"roles": [
{
"role": "dbAdmin",
"db": "products"
}
],
"inheritedRoles": [
{
"role": "readWrite",
"db": "products"
}
]
}
{
"role": "readWriteAndDbAdmin",
"db": "products",
"isBuiltin": false,
"roles": [
{
"role": "readWrite",
"db": "products"
}
],
"inheritedRoles": [
{
"role": "dbAdmin",
"db": "products"
}
]
}
Detailed Answer
Correct Answer:
After running all of the commands, the output of the getRole() command will
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 21/32
28/10/2019 MongoDB University
be the following:
COPY
{
"role": "readWriteAndDbAdmin",
"db": "products",
"isBuiltin": false,
"roles": [
{
"role": "readWrite",
"db": "products"
},
{
"role": "dbAdmin",
"db": "products"
}
],
"inheritedRoles": [
{
"role": "dbAdmin",
"db": "products"
},
{
"role": "readWrite",
"db": "products"
}
]
}
Question 9
Transport layer
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 22/32
28/10/2019 MongoDB University
Password salting
Detailed Answer
Transport layer
Question 10
Replication
Question 1
Question 2
Which command would you use to add an arbiter to an existing replica set on
host mongo2, running on port 27017?
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 23/32
28/10/2019 MongoDB University
rs.addArb("mongo2:27107")
Detailed Answer
Correct Option
rs.addArb("mongo2:27107") COPY
Incorrect Options:
Question 3
Question 4
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 24/32
28/10/2019 MongoDB University
Question 5
Question 6
Question 7
Question 8
Question 9
Question 10
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 25/32
28/10/2019 MongoDB University
Detailed Answer
Correct Answer
Incorrect Answers
Sharding
Question 1
Question 2
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 26/32
28/10/2019 MongoDB University
Question 3
Question 4
scatter gather queries can be triggered by using your shard key in your
query predicates
the mongos has to go to each shard to check if the shard has the
requested documents
Detailed Answer
Incorrect Options:
scatter gather queries can be triggered by using your shard key in your query
predicates
Using the shard key in your query predicates prevents scatter gather
queries by routing the query to the correct shard. This is due to the config
server being aware of the distribution of the values across the cluster.
Scatter gather queries are not performant as the mongos has to go to each
shard to check if the requested documents are present.
Correct Option
the mongos has to go to each shard to check if the shard has the requested
documents
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 27/32
28/10/2019 MongoDB University
Not querying on your shard key causes scatter gather queries. As a result,
the mongos has no way of checking which shard the data resides on. This
causes the mongos needs to route the query to each shard to gather the
result set.
Question 5
Detailed Answer
Correct Answer:
Using a compound shard key creates more possibilities for the value
of the shard key, by using each unique combination of all the fields in
the key.
Incorrect Answers:
I th b f h d
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 28/32
28/10/2019 MongoDB University
Increase the number of shards.
Adding more shards will decrease the load on each shard, but this
will not increase the cardinality of the shard key.
This will be a result of increasing the cardinality of the shard key, not
a cause.
Question 6
At which point does the balancer decide to start moving chunks from one shard
to another?
Detailed Answer
Correct Options:
Question 7
Question 8
Question 9
You have the following operational requirements and benchmarks within your
organization:
Detailed Answer
Scenario C: While the cost of vertically scaling is acceptable, we're already using
2.8TB of disk space. Considering we benchmarked a backup operation and
restore operation at 15 minutes each with 1.5TB of data, we're already beyond
our SLAs. Sharding should have already been considered much sooner.
Scenario A: This is a real world scenario that zone sharding was designed to
address, and depending on the type of information your organization stores you
may be subject to regulations requiring you to store data in a specific
geographical area. Considering the majority of users are located in the Americas
approaching SLA limits, sharding is more appropriate here than relocating all
data to the EU.
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 31/32
28/10/2019 MongoDB University
Question 10
https://university.mongodb.com/exam/practice/DBA/results/5db694c616d2374c4dbace69 32/32