MongoDB - Java

MongoDB - PHP

MongoDB - Advanced

MongoDB - Useful Resources

MongoDB Online Quiz



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

Answer : C

Explanation

The skip and limit functions are applies linearly and hence it will first skip documents 1-5, and then return documents 6-10.

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.

Answer : C

Explanation

MongoDB does not support things like ACID Transactions or atomicity across collections or relationships like SQL.

Answer : B

Explanation

{multi:true} should be used for this purpose. By default, MongoDB will update only the first document.

Q 5 - Which are the ONLY ways to project portions of an array?

A - $elemMatch

B - $slice

C - $

D - All of the above

Answer : D

Explanation

$elemMatch, $slice, and $ are the only way to project portions of an array. For e.g. you cannot use {tags.0:1} for projection.

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/} } )

C - db.posts.find( { $like: {author: /john/} } )

D - db.posts.find( { author: /^john^/ } )

Answer : A

Explanation

db.posts.find( { author: /john/ } )

Q 7 - What is the minimum sensible number of voting nodes to a replica set?

A - 2

B - 3

C - 4

D - 5

Answer : B

Explanation

The minimum number of sensible number of voting nodes is 3.

Answer : A

Explanation

MongoDB cannot create a unique index on the specified index field(s) if the collection already contains data that would violate the unique constraint for the index. The syntax for the same is db.collection.createIndex( { a: 1 }, { unique: true } )

Answer : A

Explanation

In the aggregation pipeline, it is not necessary to have a $group or $project or $match before the $sort operation.

Answer : C

Explanation

If you need to rebuild indexes for a collection you can use the db.collection.reIndex() method to rebuild all indexes on a collection in a single operation. This operation drops all indexes, including the _id index, and then rebuilds all indexes.

mongodb_questions_answers.htm
Advertisements