Following quiz provides Multiple Choice Questions (MCQs) related to MongoDB Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - Which of the following is correct explanation of MongoDB processes?
A - mongod.exe is the shell process and mongo.exe is the actual database process
B - mongo.exe is the shell process and mongod.exe is the actual database process
C - mongos.exe is the MongoDB server process needed to run database
D - mongodump.exe can be used to import database backup dump
The core components in the MongoDB package are: mongod, the core database process; mongos the controller and query router for sharded clusters; and mongo the interactive MongoDB Shell.
Q 2 - What is the maximum size of a MongoDB document?
The maximum BSON document size is 16 megabytes. The maximum document size helps ensure that a single document cannot use excessive amount of RAM or, during transmission, excessive amount of bandwidth.
Q 3 - Which of the following commands can cause the database to be locked?
All the above commands wither result in a read lock or a write lock or both.
Q 4 - Which option should be used to update all the documents with the specified condition in the MongoDB query?
A - updateAll instead of update
B - specify {multi : true} as the third parameter of update command
C - specify {all: true} as the third parameter of update command
D - specify {updateAll: true} as the third parameter of update command
{multi:true} should be used for this purpose. By default, MongoDB will update only the first document.
Q 5 - Which option should be used with findAndModify() command to return the modified document instead of the pre-modification document?
A - findAndModify by default returns the pre-modification document
C - Use the POST version of findAndModify called findAndModifyPost
When true, returns the modified document rather than the original. The findAndModify() method ignores the new option for remove operations. The default is false.
Q 6 - What is the equivalent command in MongoDB for the following SQL query?
SELECT * FROM posts WHERE author like "%john%"
A - db.posts.find( { author: /john/ } )
B - db.posts.find( { author: {$like: /john/} } )
db.posts.find( { author: /john/ } )
Q 7 - 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?
You have to give state and city as the key to group by and then calculate the sum of the population in each city.
Q 8 - 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?
{ “_id”:1, “post_text”:”This is a sample post”, “author”:”Tom”, “comments”:[ { “author”:”Joe”, “comment_text”:”This is comment 1” }, { “author”:”Leo”, “comment_text”:”This is comment 2” } ] }
A - db.posts.createIndex({“comments.$.author":-1});
B - db.posts.createIndex({“comments.author":-1});
C - db.posts.createIndex({“comments.author":1});
D - db.posts.createIndex({“comments.$.author": {“$desc”:1}});
We can access the document fields within an array using dot notation. And for indicating the index sorting, we just have to mention 1 or -1.
Q 9 - Which of the tags in a replica set configuration specify the operations to be read from the node with the least network latency?
Operations read from member of the replica set with the least network latency, irrespective of the member’s type.
Q 10 - When should we consider representing a one-to-many relationship in an embedded collection instead of separate collection?
A - When the many is very large
If the many is very large, then we should create separate collection, else the document size would go on increasing.