0% found this document useful (0 votes)
39 views43 pages

C100DBA MongoDB

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 43

MongoDB

C100DBA Exam
MongoDB Certified DBA Associate Exam

Questions & Answers


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. Joins

C. Authentication

Answer(s): A,B
2. The following aggregation option is used to specify the specific fields
that needs to be passed to the next stage of the aggregation pipeline:

A. $project

B. $aggregate

C. $match

D. $group

Answer(s): A

3. In a collection that contains 100 post documents, what does the


following command do? db. posts. find().skip(5).limit(5)

A. Skip and limit nullify each other. Hence returning the first five
documents.

B. Skips the first five documents and returns the next five

C. Limits the first five documents and then return them in reverse order

D. Skips the first five documents and returns the sixth document five
times
Answer(s): B
4. What tool do you use to see if you have a problem in the consumption of
disk I / 0?

A. Mongoperf

B. mongofile

Answer(s): A

5. Which of the following is supported by MongoDB?

A. Transaction Management

B. ACID Transactions

C. Journaling

D. Relationships between Collections (Primary Key Foreign Key)

Answer(s): C
6. The MongoDB explain() method does not support which of the following
verbosity mode:

A. executionStats

B. queryPlanner

C. customExecutionStats

D. allPlansExecution

Answer(s): A
7. Consider a collection posts which has fields: Jd, post_text, post_author,
post_timestamp, post_tags etc. Which of the following query retrieves
ONLY the key named post_text from the first document retrieved?

A. db.posts.finOne({},{_id:0, post_text:1})
B. db.posts.findOne({post_text: 1})

C. db.posts.find({},{_id:Of post_text:1})

D. db.posts.finOne«},{post_text:l})

Answer(s): A
8. In a sharded replica set environment, the w Option provides ability for
write concern and j Option provides ability for the data to be written on disk
journal. Consider that we have a seven member replica set and we want to
assure that the writes are committed to journal.
What should be the value of j?

A. 1

B. 2

C. 0

D. 7

Answer(s): B
9. Aggregation Pipelines have a limit of:

A. 2 MB document and 100 MB RAM

B. 16 MB document and 100 MB RAM

C. No limit on document and 100 MB RAM

D. 2 MB document and no limit on RAM

Answer(s): B
10. What is the maximum size of a MongoDB document?

A. 2 MB

B. 12 MB

C. There is no maximum size. It depends on the RAM.


D. 16 MB

Answer(s): D
11. If the value of totalKeysExamined is 30000 and the value of
totalDocsExamined is 0, which of the following option is correct?

A. None of the above

B. The query used an index to fetch the results

C. The query returned 0 documents

D. The query returned 30000 documents after scanning the documents

Answer(s): B
12. Given a collection posts as shown below having a document array
comments, which of the following command will create an index on the
comment author descending?

A. db.posts.createIndex({commerits.$.author":-l});
B. db.posts.createIndex({comments.$.author": {$desc:l>});

C. db.posts.createIndex({comments.author":-l});

Answer(s): C

13. Which option should be used to update all the documents with the
specified condition in the MongoDB query?

A. specify {all: true} as the third parameter of update command

B. updateAII instead of update

C. specify {updateAII: true} as the third parameter of update command

D. specify {multi : true} as the third parameter of update command

Answer(s): D
14. Which mongodb tool is used to report details on number of database
operations in MongoDB?

A. mongorestore

B. mongostat

C. mongodump

D. mongotop

Answer(s): B
15. In a sharded replica set environment, the w Option provides ability for
write concern and j Option provides ability for the data to be written on disk
journal. Consider that we have a seven member replica set and we want to
assure that the writes are committed to journal.
What should be the value of j?

A. 7

B. 2
C. 1

D. 0

Answer(s): C
16. 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. secondaryPreferred

B. Secondary

C. nearest

D. primary

E. primaryPreferred

Answer(s): E
17. Which of the following operators is used to updated a document
partially?

A. $set

B. $update

C. $project

D. $modify

Answer(s): A
18. What is the first task that a secondary would perform on being
prompted by another secondary for an election?

A. Start the election process for primary

B. Vote for the first secondary so that it would become the next primary

C. Vote for itself and then call for election


D. Connect to primary to confirm its availability

Answer(s): D
19. 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.sample.find( { "$or" : [ { "a" : { "$in" : [ 3, 10] > }, { "b" : { "$lt" : 2 > > ] > )

A. {''__id" :3, "a": 4, "c" :0, "b" :14}

B. {''_Jd" :7, "a": 8, "c" :1, "b" :7}

C. {".Jd" :6, "a": 1, "c" :1, "b" :5}

D. { ''\Jd" :9, "a": 17, "c": 1, "b": 1}

E. { \Jd" :10,"a": 3, "c": 1, "b": 1}

F. {".Jd" :: 2, "a": 2, "c" :: 0, "b": 1}

G. {".Jd" :: 4, "a": 5, "c" :: 0, "b": 17}

H. {".Jd" :: 1, "a": 0, "c" :: 0, "b": 2}

I. {".Jd" :: 5, "a": 3, "c" :: 0, "b": 12}

J. {".Jd" :: 8, "a": 11, "c": 1, "b": 0}

Answer(s): D,E,F,I,J
20. JSON stands for

A. JavaScript Object Notation

B. JavaScript Object Naming

C. JavaScript Object Notice

D. None of the above

Answer(s): A
21. What is the replication factor for a replicated cluster with 1 primary, 3
secondaries with one of them hidden. The set also has an arbiter?

A. None of the above

B. 5

C. 3

D. 4

Answer(s): D
22.Which operations add new documents to a collection?

A. Create

B. update

C. insert

D. delete

Answer(s): A,C
23. Consider that you have a collection called population which has fields
state and city. Which of the following query will calculate the population
grouped by state and city?

A. db.population.aggregate( [{ $group: { _id: { state: "$state", city;


"$city" },pop: { $sum: 1 > > >] )

B. db.population.aggregate( [{ $group: { _id: { state: Estate", city: "$city"


},pop: { $pop: 1 } } }] )

C. db.population.aggregate( [{ $group: { _id: { state: Estate", city:


n$city" },pop: { $sum:
"$pop" } } }] )

D. db.population.aggregate( [{ $group: { _id: { city: "$city" },pop: { $sum:


"$pop" } } }] )Multi Document Transaction is not supported by
MongoDB
Answer(s): C
24. Which of the following is true about sharding?

A. Creating a sharded key automatically creates an index on the


collection using that key

B. We cannot change a shard key directly/automatically once it is set up

C. A sharded environment does not support sorting functionality since


the documents lie on various mongod instances

D. Sharding is enabled at the database level

Answer(s): B
25. Which of the tags in a replica set configuration specify the operations
to be read from the node with the least network latency?

A. netLatency

B. secondaryPreferred

C. nearest

D. primaryPreferred

Answer(s): C
26. What is the output of the following program?

A. 60 s

B. 1s

C. 100 s

D. 100 ms

Answer(s): A
27. Which node in a replica set does accept write operation?
A. arbiter

B. hidden

C. primary

D. secondary

Answer(s): C
28. Using an arbiter allows one to easily ensure an odd number of voters in
replica sets. Why is this important?

A. To help in disaster recovery

B. To protect agains network partitions

C. To enable certain read preference settings

D. To add greather redundancy

E. For more efficient backup operations

Answer(s): B
29. Which of the following statements are true about the $match pipeline
operator? Check all that apply.

A. You should use it early as possible in the pipeline

B. It can be used as many time as needed.

C. It has a sintax similar to findQ commands.

Answer(s): A,B,C
30. Which of the following is a valid Replica Set configuration if you want:

1-Have 3 copies of everything

2- That RS3 is never primary

2- That RSI and RS2 can be primary?


You had to see the different configurations, RS3 could be hidden or priority
0 (But not a referee because we need

3 replicas), while RSI and RS2 could NOT have priority 0 or be hidden or
anything like that

In a 4-member RS RSO , RSI, RS2 and RS3 + Referee, RSO (primary) falls
after some write operations that have

replicated RSI and RS2 (but NOT RS3), who can get up as the new primary?

The configuration comes and in it we see that RS2 has a hidden: true (or a
priority: 0, (I don't remember)

A. ORS1

B. ORS2

C. ORS3

D. O arbiter

E. RSO

Answer(s): A
31. 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. missing operations will need to be manually re-performed

B. the secondary with the most current oplog will be elected primary

C. reads will be stale until the primary comes back up

D. the primary may roll back the operations once it recovers

E. the most current secondary will roll back the operations following the
election
Answer(s): B
32. Which command can be used to rebuild the indexes on a collection in
MongoDB?

A. db.collection.createlndex({relndex:l})

B. db.collection.reIndex({author:l})

C. db.collection.relndexQ

D. db.collection.createIndex({author:l}).reIndex()

Answer(s): C
33. What does the totalKeysExamined field returned by the explain method
indicate?

A. Number of documents that match the query condition

B. Number of index entries scanned

C. Details the completed execution of the winning plan as a tree of


stages

D. Number of documents scanned

Answer(s): B
34. In order to ensure that you can maintain high availability in the face of
server failure, you should implement which of the following?

A. Sharding

B. Properly defined user roles

C. Replication

D. Put indexes on all of your documents

E. The proper storage engine

Answer(s): C
35. Which option can be used with update command so that a new
document gets created if no matching document is found based on the
query condition?

A. upsert command instead of update command

B. {update: true, insert: true} as the third parameter of update command

C. This has to be handled in application code (Node.js, PHP, JAVA, C#,


etc.) and cannot be handled in mongo shell query

D. Specify {upsert : true } as the third parameter of update command

Answer(s): D
36. Dada una coleccion, cuales devuelve con la siguiente query
db.coleccion.find({nombre:"ruben",apellido:"gomez"},{nombre:l,apellido:l,
aficion:l});

A. { "-id" : Objectld("580a42b5dfblb5al7427d302"), "nombre" : "ruben",


"apellido" : "gomez", "aficion" : v u "flipar" }

B. { "_id" : Objectld("580a42acdfblb5al7427d301"), "nombre" : "Luis",


"apellido" : "gomez", "aficion" : u "flipar" }

C. { "_id" : Objectld("580a42acdfblb5al7427d301"), "nombre" : "ruben",


"apellido" : "Pablo" , "aficion" : u "flipar"}

D. { "_id" : Objectld("580a42acdfblb5al7427d301"), "nombre" : "ruben",


"apellido" : "gomez" >

Answer(s): A,D
37. MongoDB is

A. None of the above

B. Object-oriented DBMS

C. Relational DBMS

D. Document-oriented DBMS
Answer(s): D
38. Which are the ONLY ways to project portions of an array?

A. $slice

B. $

C. All of the above

D. $ elemMatch

Answer(s): C
39. In a replicated cluster, which of the following node would only be used
during an election?

A. arbiter

B. primary

C. hidden

D. secondary

Answer(s): A
40. Which of the following node is used during election in a replication
cluster?

A. primary

B. arbiter

C. hidden

D. secondary

Answer(s): B
41. You have designed a web application with mongoDB. You have
configured replication. The replica set is in place and function properly.
What happens in case of failure?
A. Switchover needs to be done manually

B. Failover happens automatically

C. Switchover happens automatically

D. Failover needs to be done manually

Answer(s): B
42. You have a replicated cluster with 1 primary, 3 secondary, 1 arbiter. One
of the secondary is hidden. What is the replication factor of this replicated
cluster?

A. 7

B. 03

C. 04

D. 06

Answer(s): C
41. In a replica set, a_________number of members ensures that the replica
set is always able to select a primary.

A. Even

B. Odd

C. 2

D. Depends on the application architecture

Answer(s): B
42. Consider that you have a collection called population which has fields
state and city. Which of the following query will calculate the population
grouped by state and city?

A. db.population.aggregate( [{ $group: { _id: { state: "$state", city:


"$city" },pop: { $pop: 1 } } }] )
B. db.population.aggregate( [{ $group: { _id: { city: "$city" },pop: { $sum:
"$pop" } } }] )Multi Document Transaction is not supported by
MongoDB

C. db.population.aggregate( [{ $group: { _id: { state: Estate", city: "$city"


},pop: { $sum:
"$pop" } } }] )

D. db.population.aggregate( [{ $group: { _id: { state: Estate", city: "$city"


},pop: { $sum: 1 > > >] )

Answer(s): C
43. Which of the following operator can be used to limit the number of
documents in an array field of a document after an update is performed?

A. $arrayLimit

B. $push along with $each, $sort and $slice

C. $removeFromSet

D. None of the above

Answer(s): B
44. Which mongodb tools allow us to work with our data in a human
readable format?

A. mongoexport

B. mongostat

C. mongoimport

D. mongodump

Answer(s): A,C
45. Write the command(s) are correct to enable sharding on a database
"testdb" and shard a collection "testCollection" with _id as shard key.
A. sh.enableSharding("testdb") &
sh.shardCollection("testdb.testCollection", {_id : 1 }, true )

Answer(s): A
46. Which of the following is true about aggregation framework?

A. Each aggregation operator need to return atleast one of more


documents as a result

B. the aggregate command operates on a multiple collection

C. A single aggregation framework operator can be used more than


once in a query

D. Pipeline expressions are stateless except accumulator expressions


used with $group operator

Answer(s): A,C,D
47. What is the use of mongodump and mongorestore tools?

A. backup mongodb deployment

B. audit mongodb deployment

C. performance tune mongodb deployment

D. replicate mongodb deployments

Answer(s): A
48. 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

Answer(s): A,B
49. When should we consider representing a one-to-many relationship in
an embedded collection instead of separate collection?

A. When the many is not very large

B. When the many is very large

C. Always

D. Never

Answer(s): A
50. Which of the following command is used to get all the indexes on a
collection?

A. db.collection.showIndexes()

B. db.collection.findlndexes()

C. db.showIndexes()

D. db.collection.getlndexesQ

Answer(s): D
51. If you have created a compound index on (A,B, C) which of the
following access pattern will not be able to utilize the index?

A. A, B, C

B. A

C. B, C

D. A, B

Answer(s): C
52. Mongodb does provide high availability via which option?

A. Replication
B. Indexing

C. Sharding

D. Journaling

Answer(s): A
53. You are in a sharded cluster. What will you do prior to initiating backup
in sharded cluster?

A. db.stopBalancer()

B. db.stopserver()

C. sh.stopBalancer()

D. sh.stopserverQ

Answer(s): C
54. You are comparing values of different BSON types in mongodb. You
want to compare from lowest to highest. Which comparison order is used?

A. MinKey, Null, Numbers,Symbol, String,Object,Array,BinData

B. MinKey, Null, Numbers,Object,Array,BinData,Symbol, String

C. Object/Array^inData/Symbol,MinKey, Null, Numbers,String

D. Objec^Array^inData,Symbol, String,MinKey, Null, Numbers

Answer(s): A
55. Below is a sample document in a given collection test.

{ a : 5, b : 3, c: 2, d : 1 >

Given a compound index { a: 1, b:l, c:l, d:l}, Which of the below query will
not use in- memory sorting? Select all valid.

A. db.test.find( { a: 5, b: 3 } ).sort( { c: 1, d : 1 } )
B. db.test.find( { a: 5, b: 3 } ).sort( { a: 1} )

C. db.test.find( { a: 5, b: 3 } ).sort( { a: 1, b: 1, c: 1 > )

D. db.test.find( { a: 5, b: 3 } ).sort( {c: 1 } )

Answer(s): A,D
56. Which of the following is incorrect statement about find and findOne
operations in MongoDB?

A. findQ returns all the documents in a collection while findOne()


retrieves only the first one.

B. find.limit(l) is not the same query as findOne()

C. findOneQ returns the actual first document retrieved from a collection

D. findQ and findOneQ returns cursors to the collection documents

Answer(s): D
57. Which of the following aggregate commands in MongoDB uses a
pipeline approach with the goals of improving the aggregation
performance?

A. mapReduce

B. group

C. aggregate

D. All of the above

Answer(s): C
58. `$set' sets the value of

A. Code block

B. Name/value pair

C. Key
D. None of the above

Answer(s): C
59. 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.

db.sayings.find( { $text : { $search : "fact find" } } )

A. { _id : 3, quote : "Nobody will ever catch me." }

B. { _id : 1, quote : "That's a fact, Jack." }

C. { _id : 2, quote : "Find out if that fact is correct." }

Answer(s): B,C
60. What tool would you use if you want to save a gif file in mongo?

A. mongofile

B. Mongoperf

Answer(s): A
61. Which option can be used with update command so that a new
document gets created if no matching document is found based on the
query condition?

A. upsert command instead of update command

B. This has to be handled in application code (Node.js, PHP, JAVA, C#,


etc.) and cannot be handled in mongo shell query

C. {update: true, insert: true} as the third parameter of update command

D. Specify {upsert : true } as the third parameter of update command


Answer(s): D
62. What is the maximum size of a MongoDB document

A. 16 MB

B. 12 MB

C. 2 MB

D. There is no maximum size. It depends on the RAM.

Answer(s): A
63. The oplog (operations log) is a special capped collection that keeps a
rolling record of all operations that modify the data stored in your
databases. All the replica set members contain a copy of the oplog in the
following collection:

A. <replicasetid>.oplog.rs

B. oplog.rs

C. <database>..oplog.rs

D. local.oplog.rs

Answer(s): D
64. In a collection that contains 100 post documents, what does the
following command do? db. posts. find().skip(5).limit(5)

A. Skip and limit nullify each other. Hence returning the first five
documents

B. Limits the first five documents and then return them in reverse order

C. Skips the first five documents and returns the sixth document five
times

D. Skips the first five documents and returns the next five

Answer(s): D
65. In a sharded replicas set environment with multiple mongos servers,
which of the following would decide the mongos failover?

A. mongos

B. mongo shell

C. individual language drivers

D. mongod

Answer(s): C
66. In what format does mongodump creates backup files?

A. BSON

B. JSON

C. SOAP

D. XML

Answer(s): A
67. In which of the following scenarios is sharding not the correct option.
Select all that apply.

A. The write operations on the collection are low

B. The write operations on the collection are very high

C. The working set in the collection is expected to grow very large in


size

D. The collection is a read intensive collection with less working set

Answer(s): A,D
68. Consider the following posts document:
Which of the following queries will return the documents but with only the
first two tags in the tags array?

A. db.posts.find({author:"Tom"».limit({tags:2})

B. db.posts.find({author:"Tom"».limit($slice:{tags:2>)

C. Both "db.posts.find({author:"Tom"},{tags:{$slice:2}})" and


"db.posts.find({author:"Tom"}).limit($slice: {tags:2})" are valid. $slice
works both with projection and limit.

D. db.posts.find({author:"Tom">,{tags:{$slice:2»)

Answer(s): D
69. Given a collection posts as shown below having a document array
comments, which of the following command will create an index on the
comment author descending?
A. db.posts.createIndex({^comments.$.author":-l});

B. db. posts.createIndex({^comments.author" :1});

C. db.posts.createIndex({^commerits.author";-!});

Answer(s): C
70. Which of the following collections stores authentication credentials in
MongoDB?

A. test.users

B. local.users

C. system.users

D. users.users

Answer(s): C
1. Which features of relational database management systems were
deliberately omitted in MongoDB and help us to obtain horizontal
scalability? Check all that apply.

Answer :
 Multi-statement transactions
 Joins

2. In a collection that contains 100 post documents, what does the following
command do? db. posts. find().skip(5).limit(5)

Answer :
 Skips the first five documents and returns the next five

3. Which of the following is supported by MongoDB?

Answer :
 Journaling

4. Aggregation Pipelines have a limit of:

Answer :
 16 MB document and 100 MB RAM

5. If the value of totalKeysExamined is 30000 and the value of


totalDocsExamined is 0, which of the following option is correct?

Answer :
 The query used an index to fetch the results

6. Which of the following operators is used to updated a document partially?


Answer :
 $set

7. What is the replication factor for a replicated cluster with 1 primary, 3


secondaries with one of them hidden. The set also has an arbiter?

Answer :
 4

8. Which operations add new documents to a collection?

Answer :
 Create
 insert

9. Hat RSI and RS2 can be primary? You had to see the different
configurations, RS3 could be hidden or priority 0 (But not a referee because
we need 3 replicas), while RSI and RS2 could NOT have priority 0 or be
hidden or anything like that . In a 4-member RS RSO, RSI, RS2 and RS3 +
Referee, RSO (primary) falls after some write operations that have replicated
RSI and RS2 (but NOT RS3), who can get up as the new primary?
The configuration comes and in it we see that RS2 has a hidden: true (or a
priority: 0, (I don't remember)

Answer :
 ORS1

10. 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?
In order to ensure that you can maintain high availability in the face of server
failure, you should implement which of the following?
Answer :
 Replication
11. MongoDB is________.

Answer :
 Document-oriented DBMS

12. In a replicated cluster, which of the following node would only be used
during an election?

Answer :
 arbiter

13. The following aggregation option is used to specify the specific fields that
needs to be passed to the next stage of the aggregation pipeline:

Answer :
 $project

14. The MongoDB explain() method does not support which of the following
verbosity mode:

Answer :
 executionStats

15. Consider a collection posts which has fields: Jd, post_text, post_author,
post_timestamp, post_tags etc. Which of the following query retrieves ONLY
the key named post_text from the first document retrieved?

Answer :
 db.posts.finOne({},{_id:0, post_text:1})
16. Which option should be used to update all the documents with the
specified condition in the MongoDB query?

Answer :
 specify {multi: true} as the third parameter of update
command

17. Which mongodb tool is used to report details on number of database


operations in MongoDB?

Answer :
 mongostat

18. In a sharded replica set environment, the w Option provides ability for
write concern and j Option provides ability for the data to be written on disk
journal. Consider that we have a seven member replica set and we want to
assure that the writes are committed to journal. What should be the value of
j?

Answer :
 1

19. 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?

Answer :
 primaryPreferred

20. What is the first task that a secondary would perform on being prompted
by another secondary for an election?

Answer :
 Connect to primary to confirm its availability

21. Consider that you have a collection called population which has fields
state and city. Which of the following query will calculate the population
grouped by state and city?

Answer :
 db.population.aggregate( [{ $group: { _id: { state: Estate ", city: n$city
" },pop: { $sum: "$pop " } } }] )
22. Which of the following is true about sharding?

Answer :
 We cannot change a shard key directly/automatically once it is set up

23. Which of the tags in a replica set configuration specify the operations to
be read from the node with the least network latency?
Answer :
 nearest

24. Which node in a replica set does accept write operation?


Using an arbiter allows one to easily ensure an odd number of voters in
replica sets. Why is this important?

Answer :
 To protect agains network partitions

25. Which of the following statements are true about the $match pipeline
operator? Check all that apply.

Answer :
 You should use it early as possible in the pipeline
 It can be used as many time as needed
 It has a sintax similar to findQ commands.
26. Which command can be used to rebuild the indexes on a collection in
MongoDB?

Answer :
 db.collection.relndexQ

27. What does the totalKeysExamined field returned by the explain method
indicate?

Answer :
 Number of index entries scanned

28. Which option can be used with update command so that a new document
gets created if no matching document is found based on the query condition?

Answer :
 Specify {upsert : true } as the third parameter of update command

29. Dada una coleccion, cuales devuelve con la siguiente query


db.coleccion.find({nombre: "ruben ",apellido: "gomez
"},{nombre:l,apellido:l,aficion:l});

Answer :
 { "-id " : Objectld( "580a42b5dfblb5al7427d302 "), "nombre " : "ruben
", "apellido " : "gomez ", "aficion " : v u "flipar " }
 { "_id " : Objectld( "580a42acdfblb5al7427d301 "), "nombre " : "ruben
", "apellido " : "gomez " >

30. Which of the following node is used during election in a replication


cluster?

Answer :
 arbiter
31. Which of the documents below will be retrieved by the following query?
Assume the documents are stored in a collection called "sample ". (Choose
all that apply)

Answer :
 {''__id " :3, "a ": 4, "c " :0, "b " :14}
 { ''Jd " :9, "a ": 17, "c ": 1, "b ": 1}
 { Jd " :10, "a ": 3, "c ": 1, "b ": 1}
 { ".Jd " :: 2, "a ": 2, "c " :: 0, "b ": 1}

32. Which features of relational database management systems were


deliberately omitted in MongoDB and help us to obtain horizontal
scalability? Check all that apply.
 Multi-statement transactions
 Joins
 Authentication

33. The following aggregation option is used to specify the specific fields
that needs to be passed to the next stage of the aggregation pipeline:
 $project
 $aggregate
 $match
 $group

34. In a collection that contains 100 post documents, what does the
following command do? db. posts. find().skip(5).limit(5)
 Skip and limit nullify each other. Hence returning the first five documents.
 Skips the first five documents and returns the next five
 Limits the first five documents and then return them in reverse order
 Skips the first five documents and returns the sixth document five times

35. Which of the following is supported by MongoDB?


 Transaction Management
 ACID Transactions
 Journaling
 Relationships between Collections (Primary Key Foreign Key)wrong

36. The MongoDB explain() method does not support which of the following
verbosity mode:
 executionStats
 queryPlanner
 customExecutionStats
 allPlansExecution

37. Consider a collection posts which has fields: Jd, post_text,


post_author, post_timestamp, post_tags etc.

Which of the following query retrieves ONLY the key named post_text from
the first document retrieved?
 db.posts.finOne({},{_id:0, post_text:1})
 db.posts.findOne({post_text: 1})
 db.posts.find({},{_id:Of post_text:1})
 db.posts.finOne«},{post_text:l})

38. In a sharded replica set environment, the w Option provides ability for
write concern and j Option provides ability for the data to be written on disk
journal. Consider that we have a seven member replica set and we want to
assure that the writes are committed to journal.

What should be the value of j?


 1
 2
 0
 7

39. Aggregation Pipelines have a limit of:


 2 MB document and 100 MB RAM
 16 MB document and 100 MB RAM
 No limit on document and 100 MB RAM
 2 MB document and no limit on RAM

40. What is the maximum size of a MongoDB document?


 2 MB
 12 MB
 There is no maximum size. It depends on the RA
 16 MB

41. If the value of totalKeysExamined is 30000 and the value of


totalDocsExamined is 0, which of the following option is correct?
 None of the above
 The query used an index to fetch the results
 The query returned 0 documents
 The query returned 30000 documents after scanning the documents

42. Given a collection posts as shown below having a document array


comments, which of the following command will create an index on the
comment author descending?
 db.posts.createIndex({commerits.$.author":-l});
 db.posts.createIndex({comments.$.author": {$desc:l>});
 db.posts.createIndex({comments.author":-l});

43. Which option should be used to update all the documents with the
specified condition in the MongoDB query?
 specify {all: true} as the third parameter of update command
 updateAII instead of update
 specify {updateAII: true} as the third parameter of update command
 specify {multi: true} as the third parameter of update command

44. Which mongodb tool is used to report details on number of database


operations in MongoDB?
 mongorestore
 mongostat
 mongodump
 mongotop
45. In a sharded replica set environment, the w Option provides ability for
write concern and j Option provides ability for the data to be written on disk
journal. Consider that we have a seven member replica set and we want to
assure that the writes are committed to journal.

What should be the value of j?


 7
 2
 1
 0

46. 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?
 secondaryPreferred
 Secondary
 nearest
 primary
 primaryPreferred

47. Which of the following operators is used to updated a document


partially?
 $set
 $update
 $project
 $modify

48. What is the first task that a secondary would perform on being
prompted by another secondary for an election?
 Start the election process for primary
 Vote for the first secondary so that it would become the next primary
 Vote for itself and then call for election
 Connect to primary to confirm its availability
49. 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.sample.find( { "$or" : [ { "a" : { "$in" : [ 3, 10] > }, { "b" : { "$lt" : 2 > > ] > )
 {''__id" :3, "a": 4, "c" :0, "b" :14}
 {''_Jd" :7, "a": 8, "c" :1, "b" :7}
 {".Jd" :6, "a": 1, "c" :1, "b" :5}
 { ''Jd" :9, "a": 17, "c": 1, "b": 1}
 { Jd" :10,"a": 3, "c": 1, "b": 1}
 {".Jd" :: 2, "a": 2, "c" :: 0, "b": 1}
 {".Jd" :: 4, "a": 5, "c" :: 0, "b": 17}
 {".Jd" :: 1, "a": 0, "c" :: 0, "b": 2}
 {".Jd" :: 5, "a": 3, "c" :: 0, "b": 12}
 {".Jd" :: 8, "a": 11, "c": 1, "b": 0}

50. JSON stands for


 JavaScript Object Notation
 JavaScript Object Naming
 JavaScript Object Notice
 None of the above

51. What is the replication factor for a replicated cluster with 1 primary, 3
secondaries with one of them hidden. The set also has an arbiter?
 None of the above
 5
 3
 4

52. Which operations add new documents to a collection?


 Create
 update
 Insert
 delete
53. Consider that you have a collection called population which has fields
state and city.

Which of the following query will calculate the population grouped by state
and city?
 db.population.aggregate( [{ $group: { _id: { state: "$state", city; "$city" },pop: {
$sum: 1 > > >] )
 db.population.aggregate( [{ $group: { _id: { state: Estate", city: "$city" },pop: {
$pop: 1 } } }] )
 db.population.aggregate( [{ $group: { _id: { state: Estate", city: n$city"
},pop: { $sum: "$pop" } } }] )
 db.population.aggregate( [{ $group: { _id: { city: "$city" },pop: { $sum: "$pop" } } }]
)Multi Document Transaction is not supported by MongoDB

54. Which of the following is true about sharding?


 Creating a sharded key automatically creates an index on the collection using
that key
 We cannot change a shard key directly/automatically once it is set up
 A sharded environment does not support sorting functionality since the
documents lie on various mongod instances
 Sharding is enabled at the database level

55. Which of the tags in a replica set configuration specify the operations
to be read from the node with the least network latency?
 netLatency
 secondaryPreferred
 nearest
 primaryPreferred

56. What is the output of the following program?


 60 s
 1s
 100 s
 100 ms
57. Which node in a replica set does accept write operation?
 arbiter
 hidden
 primary
 secondary

58. Using an arbiter allows one to easily ensure an odd number of voters in
replica sets.

Why is this important?


 To help in disaster recovery
 To protect agains network partitions
 To enable certain read preference settings
 To add greather redundancy
 For more efficient backup operations

59. Which of the following statements are true about the $match pipeline
operator? Check all that apply.
 You should use it early as possible in the pipeline
 It can be used as many time as needed.
 It has a sintax similar to findQ commands.

60. That RSI and RS2 can be primary?

You had to see the different configurations, RS3 could be hidden or priority
0 (But not a referee because we need 3 replicas), while RSI and RS2 could
NOT have priority 0 or be hidden or anything like that .

In a 4-member RS RSO, RSI, RS2 and RS3 + Referee, RSO (primary) falls
after some write operations that have replicated RSI and RS2 (but NOT
RS3), who can get up as the new primary?
The configuration comes and in it we see that RS2 has a hidden: true (or a
priority: 0, (I don't remember)
 ORS1
 ORS2
 ORS3
 O arbiter
 RSO

61. 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?
 missing operations will need to be manually re-performed
 The secondary with the most current oplog will be elected primary
 reads will be stale until the primary comes back up
 the primary may roll back the operations once it recovers
 the most current secondary will roll back the operations following the election

62. Which command can be used to rebuild the indexes on a collection in


MongoDB?
 db.collection.createlndex({relndex:l})
 db.collection.reIndex({author:l})
 db.collection.relndexQ
 db.collection.createIndex({author:l}).reIndex()

63. What does the totalKeysExamined field returned by the explain method
indicate?
 Number of documents that match the query condition
 Number of index entries scanned
 Details the completed execution of the winning plan as a tree of stages
 Number of documents scanned
64. In order to ensure that you can maintain high availability in the face of
server failure, you should implement which of the following?
 Sharding
 Properly defined user roles
 Replication
 Put indexes on all of your documents
 The proper storage engine

65. Which option can be used with update command so that a new
document gets created if no matching document is found based on the
query condition?
 upsert command instead of update command
 {update: true, insert: true} as the third parameter of update command
 This has to be handled in application code (Node.js, PHP, JAVA, C#, etc.) and
cannot be handled in mongo shell query
 Specify {upsert : true } as the third parameter of update command

66. Dada una coleccion, cuales devuelve con la siguiente query


db.coleccion.find({nombre:"ruben",apellido:"gomez"},{nombre:l,apellido:l,
aficion:l});
 { "-id" : Objectld("580a42b5dfblb5al7427d302"), "nombre" : "ruben",
"apellido" : "gomez", "aficion" : v u "flipar" }
 { "_id" : Objectld("580a42acdfblb5al7427d301"), "nombre" : "Luis", "apellido" :
"gomez", "aficion" : u "flipar" }
 { "_id" : Objectld("580a42acdfblb5al7427d301"), "nombre" : "ruben", "apellido" :
"Pablo", "aficion" : u "flipar"}
 { "_id" : Objectld("580a42acdfblb5al7427d301"), "nombre" : "ruben", "apellido" :
"gomez">correct

67. MongoDB is
 None of the above
 Object-oriented DBMS
 Relational DBMS
 Document-oriented DBMS
68. Which are the ONLY ways to project portions of an array?
 $slice
 $
 All of the above
 $ elemMatch

69. In a replicated cluster, which of the following node would only be used
during an election?
 Arbiter
 primary
 hidden
 secondary

70. Which of the following node is used during election in a replication


cluster?
 primary
 Arbiter
 hiddenwrong
 secondary

You might also like