Limited-Time Offer: Enjoy 50% Savings! Ends in 00h 00m 00s Coupon code: 50OFF
Skip to content

Free MongoDB Certified Database Administrator C100DBA Exam Questions

Page: 1 / 12 Total 172 questions

Want more questions? Get Premium Access.

Question 1

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?

Correct Answer: B. 2

Question 2

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?

Correct Answer: C. 04
Explanation:

The replication factor is the number of data-bearing nodes that contain copies of the data. In this cluster: 1 primary + 3 secondary + 1 arbiter = 5 nodes total. However, the arbiter does not store data, and one secondary is hidden (but it still stores data). So the replication factor is 4: 1 primary + 3 secondaries (including the hidden one). The arbiter is not counted as it does not hold data.

Question 3

A collection and a document in MongoDB is equivalent to which of the SQL concepts respectively?

Correct Answer: B. Table and Row
Explanation:

In MongoDB, a collection is equivalent to a SQL table, and a document is equivalent to a SQL row. Collections are groupings of documents (similar to how tables are groupings of rows), and documents are individual records with field-value pairs (similar to how rows have column values).

Question 4

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

Correct Answer: D. Connect to primary to confirm its availability
Explanation:

When a secondary is prompted by another secondary for an election in a MongoDB replica set, the first task the secondary performs is to check its eligibility for election. It verifies whether it has the most recent oplog entries and meets the criteria to be a candidate (priority > 0, not hidden, not arbiter). If eligible, it increments its term and requests votes from other members. If not eligible, it rejects the request.

Question 5

In a replica set, a_________number of members ensures that the replica set is always able to select a primary.

Correct Answer: B. Odd
Explanation:

A MongoDB replica set should have an odd number of members to ensure proper election of a primary. Common replica set configurations use 3, 5, or 7 members. An odd number ensures that there is always a clear majority that can be achieved during elections. For example, with 3 members, 2 members form a majority; with 5 members, 3 form a majority. If a replica set has an even number of members, there can be a tie situation where neither partition can achieve a majority, resulting in no primary being elected. Therefore, odd numbers of members ensure the replica set can always select a primary even if some members fail.

Question 6

Addding the index {a:l} can potentially decrease the speed of which of the following operations? Check all that apply.

Correct Answer: A. db.collection.update({b:456>, {$inc: {a:l> }); C. db.collection.insert( { a:341})
Explanation:

Adding the index {a: 1} can potentially decrease the speed of the following operations:

  • Insert operations: MongoDB must update the index for every inserted document, adding overhead
  • Update operations: If the field 'a' is modified, the index must be updated accordingly
  • Delete operations: The index entry must be removed for each deleted document
  • Write-heavy workloads: If the collection experiences heavy write traffic but light read traffic on field 'a', the index maintenance cost may outweigh the benefits

Conversely, indexes improve query performance. The tradeoff is slower writes but faster reads on indexed fields. If reads on field 'a' are infrequent, the index may not justify its write-time cost.

Question 7

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 > > ] > )

Correct Answer: 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}; I. {'. Jd' : : 5, 'a' : 3, 'c' : : 0, 'b' : 12}; J. {'. Jd' : : 8, 'a' : 11, 'c' : 1, 'b' : 0}
Explanation:

The query db.sample.find({'$or': [{'a': {'$in': [3, 10]}}, {'b': {'$lt': 2}}]}) uses the $or operator to return documents matching EITHER condition:

  • First condition: Field 'a' has a value of 3 or 10
  • Second condition: Field 'b' has a value less than 2

A document is returned if it satisfies at least one of these conditions. The $in operator checks if the field value is in the specified array, and $lt checks if the value is less than the specified value.

Question 8

Which of the following is correct about MongoDB?

Correct Answer: A. MongoDB supports geospatial indexes

Question 9

Which of the following command is used to get all the indexes on a collection?

Correct Answer: D. db.collection.getlndexesQ
Explanation:

The db.collection.getIndexes() command (or db.collection.getIndices()) returns all indexes on a collection. This displays the index names, keys, and options for each index, including the default _id index.

Question 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?

Correct Answer: B. the secondary with the most current oplog will be elected primary
Explanation:

In a replica set with 5 members where the primary fails and operations exist in the oplog that only replicated to one secondary, the most likely scenario is:

  • The remaining 4 secondaries (and the arbiter if present) will hold an election
  • One of the secondaries with more recent oplog entries will likely be elected primary
  • The secondary that received the operations that were not replicated to others may have to rollback those operations to stay consistent with the new primary
  • This demonstrates why majority writes and journaling are important for data durability in replica sets

Question 11

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

Correct Answer: B. Number of index entries scanned
Explanation:

The totalKeysExamined field returned by the explain() method indicates how many index entries were examined while executing the query. A high number of keys examined relative to documents returned suggests the index is not selective enough. Ideally, totalKeysExamined should be close to the number of documents returned for an efficient query.

Question 12

Which of the following commands will return all the posts with number of likes greater than 100 and less than 200, both inclusive?

Correct Answer: A. db.posts.find({ likes : { $gte : 100 , $lte : 200 } } );
Explanation:

To find posts with likes greater than or equal to 100 AND less than or equal to 200, you use the $gte (greater than or equal) and $lte (less than or equal) operators. Both inclusive means you include the boundary values (100 and 200), so $gte and $lte are the correct operators to use. The query db.posts.find({likes: {$gte: 100, $lte: 200}}) returns all documents matching these criteria.

Question 13

What tool would you use if you want to save a gif file in mongo?

Correct Answer: A. mongofile
Explanation:

To save a GIF file (or any binary file) in MongoDB, you would use GridFS.

GridFS is a MongoDB specification for storing and retrieving large files that exceed the BSON document size limit of 16 MB. It works by:

  • Dividing the file into chunks, each stored as a separate document
  • Storing metadata about the file in a separate document
  • Using two collections: one for file chunks and one for file metadata

GridFS is particularly useful for:

  • Storing large binary files like images, videos, and PDFs
  • Storing files larger than 16 MB
  • Accessing portions of files without loading the entire file into memory

Tools like mongofiles provide command-line utilities for uploading and downloading files using GridFS.

Question 14

Which of the following is true about sharding?

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

Question 15

'mongoimport' command is used for

Correct Answer: A. Batch data insertion
Explanation:

The mongoimport command is used for importing data from external file formats (JSON, CSV, or TSV) into a MongoDB collection. It's the counterpart to mongoexport and is useful for loading data from external sources into your database. The basic syntax is: mongoimport --db database_name --collection collection_name --file filename.json.