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.

Q 2 - Within how much time does MongDB writes are written to the journal?

A - 60 s

B - 100 ms

C - 1 s

D - 100 s

Answer : B

Explanation

Writes are physically written to the journal within 100 milliseconds, by default.

Answer : C

Explanation

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

Answer : D

Explanation

$set sets the specific fields in the matched documents or adds them as a new field if not already present.

Q 5 - Consider the following posts document:

{
 	_id: 1,
	post_text: This is my first post,
	author: Tom,
	tags: [tutorial,quiz,facebook,learning,fun]
}

Which of the following queries will return the documents but with only the first two tags in the tags array?

A - db.posts.find({author:"Tom"},{tags:{$slice:2}})

B - db.posts.find({author:"Tom"}).limit({tags:2})

C - db.posts.find({author:"Tom"}).limit($slice:{tags:2})

D - Both a and c are valid. $slice works both with projection and limit.

Answer : A

Explanation

The $slice operator controls the number of items of an array that a query returns.

Answer : D

Explanation

Capped collections are fixed-size collections that support high-throughput operations that insert and retrieve documents based on insertion order. Capped collections work in a way similar to circular buffers: once a collection fills its allocated space, it makes room for new documents by overwriting the oldest documents in the collection.

Answer : A

Explanation

The above query basically matches all the documents having likes between 100 and 200. After that, it just specifies that aggregation is not to be done with any specific column (_id:null) and increments the count every time. Thus calculating the total such posts.

Q 8 - Which of the following aggregate commands in MongoDB uses a pipeline approach with the goals of improving the aggregation performance?

A - aggregate

B - mapReduce

C - group

D - All of the above

Answer : A

Explanation

The aggregate command in MongoDB is designed with specific goals of improving performance and usability for aggregation tasks. It uses a pipeline approach where objects are transformed as they pass through a series of pipeline operators such as $group, $match, and $sort.

Answer : A

Explanation

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

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