MongoDB MCQs

MongoDB MCQs

Our experts have gathered these MongoDB MCQs through research, and we hope that you will be able to see how much knowledge base you have for the subject of MongoDB by answering these multiple-choice questions.
Get started now by scrolling down!

1: In what language(s) is MongoDB supported?

A.   Javascript

B.   Python

C.   All of above.

D.   PHP

E.   Perl

2: The binary log of transactions used to recover the database after a crash is called the:

A.   Journal

B.   Ledger

C.   Primary Shard

D.   Master Replica

3: MongoDB's query language uses operators that start with which character?

A.   :

B.   $

C.   #

D.   @

4: TSV files should be expected to contain:

A.   Binary data logs

B.   Geographic data coordinates

C.   Document indexing for a named Collection

D.   Tab-separated text fields

5: MongoDB stores documents in structures called

A.   ODB objects

B.   JavaScript objects

C.   BSON objects

D.   JSON objects

6: To perform a search on a collection, and obtain a cursor object for the results, use:

A.   findAndModify()

B.   query()

C.   find()

D.   findOne()

7: The MongoDB database is capable of:

A.   Atomic (per document) operations

B.   Multi-table joins

C.   ACID-compliant transactions

D.   Multi-object commits with rollbacks

8: Which of the following statement are true

A.   The _id of a document need only be unique on the shard in which the document is housed

B.   If you do not specify and _id when doing an insert, the driver will create one for you

C.   You must specify and _id when inserting documents

D.   By default, there is no index on _id. It is best practice to add one if you expect to query based on _id.

9: What does MongoDB's Sharding provide?

A.   Scaling to one thousand nodes

B.   Automatic failover

C.   All of these

D.   Automatic balancing for changes in load and data distribution

E.   Easy addition of new machines without down time

10: Which of the following expressions are valid JSON documents?

A.   {Name: Schoolify, url: 'www.schoolifybd.com'}

B.   {Name: "Schoolify", url: www.schoolifybd.com}

C.   {Name: "Schoolify": url: 'www.schoolifybd.com'}

D.   {Name: "Schoolify", url: 'www.schoolifybd.com'}

E.   {Name: "Schoolify". url: 'www.schoolifybd.com'}

11: You can write custom MapReduce functions in MongoDB using:

A.   Javascript

B.   PHP

C.   Python

D.   Java

E.   Json

12: The maximum BSON document size is:

A.   8 megabytes

B.   16 megabytes

C.   4 megabytes

D.   12 megabytes

13: This replication process is

A.   asynchronous

B.   synchronous

14: Which of the following would you use to query an inventory collection to get all items of type "food" with price less than $34?

A.   db.inventory.find({type: "food", price: {$lte: 34}})

B.   db.inventory.find({type: "food", price: {$lt: 34}}).explain()

C.   db.inventory.find({type: "food", price: {$lt: 34}})

15: Which of the following is syntactically correct for searching the "posts" collection for a post with the title of "Big News Story"?

A.   posts.search({'title': 'Big News Story'});

B.   db.posts.find(title: 'Big News Story');

C.   posts.search('title': 'Big News Story');

D.   db.posts.find({title: 'Big News Story'});

16: The interactive "mongo" shell interface is based on:

A.   Python

B.   Ruby

C.   JavaScript

D.   Scala

17: How can you optimize document storage?

A.   Use shorter field names within documents

B.   (All of these)

C.   Specify an explicit, smaller _id value

D.   Embed small documents within other documents

18: Which of the following terms describe MongoDB?

A.   Configurable cache

B.   Static schema

C.   Document-oriented DBMS

D.   Relational database

19: MongoDB supports UTF-8 for strings in stored objects and queries:

A.   Always

B.   Never

C.   Sometimes

20: Instead of tables, MongoDB stores data in structures called:

A.   Tuples

B.   Pages

C.   Maps

D.   Collections

21: When a journal file holds 1 gigabyte of data, MongoDB creates a new journal file?

A.   True

B.   False

22: Which platform does MongoDB support?

A.   All of above

B.   Mac OS X

C.   Windows

D.   Linux

23: To create an index for user_name field on user collection, which of the following is the correct syntax?

A.   db.user.createIndex({user_name:1});

B.   db.user.attachIndex({user_name:1});

C.   db.user.saveIndex({user_name:1});

D.   db.user.ensureIndex({user_name:1});

24: The map-reduce operation uses a temporary collection for data processing; The benefit of this behavior is that the operations:

A.   Are more secure than they would be if performed on a named collection

B.   Can be performed concurrently on the same collection, without affecting the intermediate states

C.   Do not take up any additional space in the database

D.   Are more accurate than they would be if performed on the live data

25: Which method should be used to create an index on a collection, if it does not already exist?

A.   reIndex()

B.   createIndex()

C.   checkIndex()

D.   ensureIndex()

26: Which of the following statements are true about MongoDB

A.   MongoDB supports transactions

B.   MongoDB does not support transactions and operations are not atomic.

C.   MongoDB supports joins

D.   MongoDB does not support transactions but operations are atomic.

27: Which of the following are considered Core MongoDB operations?

A.   Create, Select, Update, Delete

B.   Create, Read, Update, Drop

C.   Create, Select, Update, Drop

D.   Create, Read, Update, Delete

28: The currently preferred replication method is called:

A.   Arbiter members

B.   Master/Slave

C.   Replica pairs

D.   Replica sets

29: The core database operations in MongoDB are abbreviated as:

A.   CRUD

B.   JSON

C.   MDB

D.   BSON

30: To atomically modify and return a single document from a collection, use:

A.   upsert()

B.   aggregate()

C.   update()

D.   findAndModify()

31: Indexes in mongodb are NOT good for:

A.   Collections which are write-intensive

B.   Collections where the number of reads is much greater than the number of writes.

32: Which feature of mongoDB is used to balance load among multiple machines?

A.   GridFS

B.   BSON

C.   Replica Sets

D.   Geospatial Indexing

E.   Sharding

33: Which statement of the followings could NOT drop an index?

A.   db.runCommand({dropIndexes:'foo', index : '*'})

B.   db.collection.dropIndex({x: 1, y: -1})

C.   db.runCommand({dropIndexes:'foo', index : {y:1}})

D.   db.myCollection.reIndex()

E.   db.collection.dropIndexes();

34: MongoDB uses GridFS to:

A.   Prevent data loss after a crash or hard shutdown

B.   Reduce and summarize large data structures

C.   Store large files, distributed as smaller pieces

D.   Index and sort extremely large sets of documents

35: In MongoDB V2.4, what type of JavaScript engine is used to execute all JavaScript on Mongo shell ?

A.   JavaScriptCore

B.   SpiderMonkey

C.   V8

D.   Futhark

E.   Rhino

36: True or False? MongoDB can have foreign keys.

A.   True

B.   False

37: The aggregation framework is most similar to which facility from the world of relational databases

A.   views

B.   Group by

C.   foreign keys

D.   constraints

38: MongoDB's Replication can be in Master-Slave form or _______ form.

A.   Sharding

B.   None of above

C.   Replications

D.   Replica Sets

39: When Storing large files in MongoDB one is encouraged to use...

A.   MongoFS

B.   GridFS

C.   BSON

D.   None of these

40: Which of the following atomic operations would you use to add a value to an array only if it does not already exist in the array?

A.   $push

B.   $pop

C.   $addToSet

D.   $inc

E.   $pull

41: Authentication in MongoDB is:

A.   Available with sharding since version 1.8.

B.   Not needed if we use a non-standard port for mongod.

C.   U udp firewall between mongod and client connections.

D.   Based on Linux user authentication.

E.   Off by default.

42: What's the difference between `save()` and `insert()` in mongo shell?

A.   None of above is correct.

B.   save() updates the document if if already exists (judges by if they already contains `_id`); inserts if it's new.

C.   No difference between them.

D.   save() updates the document if if already exists (judges by comparing them byte by byte); inserts if it's new.

E.   save() updates the document if if already exists (judges by their indexed keys); inserts if it's new.

43: MongoDB can have indexes on Array Elements?

A.   True, MongoDB indexes the first non-empty element of the array.

B.   True, MongoDB indexes each element of the array.

C.   True, MongoDB indexes the first element of the array.

D.   False

44: MongoDB uses the acronym TTL to mean:

A.   Time To Live

B.   Table Time Limit

C.   Temporary Table Listing

D.   Total Time Limit

45: Which feature of mongoDB is used for data redundancy?

A.   GridFS

B.   BSON

C.   Replica Sets

D.   Sharding

E.   Embedded Documents

A.   It allows faster, more reliable recovery after a crash

B.   It improves write performance on the journaled database

C.   It improves read performance on the journaled database

D.   It allows the use of Replica Sets in addition to Replica Pairs

47: Indexing

A.   Makes writes that involve the index faster

B.   Makes all writes faster

C.   Slows down reads that involve the index

D.   Slows down writes that involve the index

48: Which of the following is not a stage in the aggregation pipeline

A.   having

B.   limit

C.   group

D.   sort

49: An operation is said to be "idempotent" if it is proven to:

A.   Produce varying results when run multiple times, even with the same input

B.   Eventually produce consistent results, if run a sufficient number of times with the same inputs

C.   Produce consistent results over multiple runs, given the same input

D.   Produces results within linear time, compared to the number of inputs

50: Which of the following binaries handles routing of sharded queries to the proper shard?

A.   mongod

B.   mongorouter

C.   mongos

D.   mongo