MongoDB Online Quiz


Advertisements


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.

Questions and Answers

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

A - Table and Row

B - Table and Column

C - Column and Row

D - Database and Table

Answer : A

Explanation

The way SQL databases stores data rows in a table, MonngoDB stores documents inside collections.

Answer : A

Explanation

$type is used for all the operations involving checking the type of a field in MongoDB. 10 represents the BSON value for null.

Q 3 - Consider that our posts collection contains an array field called tags that contains tags that the user enters.

{
            _id: 1,
            tags: [“tutorial”, “fun”, “learning”],
            post_text: “This is my first post”,	
            //other elements of document  	
} 

Which of the following commands will find all the posts that have been tagged as tutorial.

A - db.posts.find( { tags : "tutorial" } );

B - db.posts.find( { tags : ["tutorial"] } );

C - db.posts.find( { $array : {tags: "tutorial"} } );

D - db.posts.findInArray( { tags : "tutorial" } );

Answer : A

Explanation

Searching an array is no different than searching a normal field. Hence the first option.

Q 4 - Consider that you are using { upsert : true } option in your update command. Which of the following parameters will be used to determine if any new documents were inserted:

A - nMatched

B - nInserted

C - nModified

D - nUpserted

Answer : D

Explanation

The nUpserted shows the number of documents that were added during the update operation.

Answer : B

Explanation

explain.executionStats.totalKeysExamined indicates the number of index entries scanned.

Answer : D

Explanation

There is no system collection to store database preferences.

Q 7 - 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 - $match

B - $project

C - $group

D - $aggregate

Answer : B

Explanation

The $project operator passes along the documents with only the specified fields to the next stage in the pipeline. The specified fields can be existing fields from the input documents or newly computed fields.

Q 8 - What is a replica set node which does not maintain its own data but exists only for voting purpose called?

A - Secondary

B - Arbiter

C - Delayed

D - Hidden

Answer : B

Explanation

We may add an extra mongod instance to a replica set as an arbiter. Arbiters do not maintain a data set. Arbiters only exist to vote in elections. If your replica set has an even number of members, add an arbiter to obtain a majority of votes in an election for primary. Arbiters do not require dedicated hardware

Q 9 - Which of the following operators can reverse the effects of a double unwind operation?

A - $push

B - $wind

C - $wind.$wind

D - Can’t be reversed.

Answer : A

Explanation

An unwind operation unwinds on an array field and creates separate documents. If you unwind it again same thing happens again. So if you had one document which had two arrays, the first array had 2 values and second array has 3 values. Unwinding this document two times will give 6 document. Now to combine them back, you can use the $push operator.

Q 10 - Which index is used to index the content stored in arrays?

A - Multikey Index

B - Compound Index

C - Text Index

D - Sparse Index

Answer : A

Explanation

MongoDB uses multikey indexes to index the content stored in arrays. If you index a field that holds an array value, MongoDB creates separate index entries for every element of the array.


mongodb_questions_answers.htm

Advertisements