This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “SQL to Aggregation Mapping Chart”.
1. __________ references the root document, i.e. the top-level document, currently being processed in the aggregation pipeline stage.
a) CURRENT
b) ROOT
c) PRUNE
d) All of the mentioned
View Answer
Explanation: CURRENT is modifiable.
2. Point out the wrong statement.
a) Variables can hold any BSON type data
b) Aggregation expressions can use both user-defined and system variables
c) To access the value of the variable, use a string with the variable name prefixed with double dollar signs ($$)
d) None of the mentioned
View Answer
Explanation: If the variable references an object, to access a specific field in the object, use the dot notation; i.e. “$$<variable>.<field>”.
3. Which of the operator is similar to order by clause in RDBMS?
a) $sort
b) $match
c) $sortby
d) None of the mentioned
View Answer
Explanation: In the mongo shell, when you assign the cursor returned from the find() method to a variable using the var keyword, the cursor does not automatically iterate.
4. Which of the following provides similar functionality to join?
a) $unwindelem
b) $unwind
c) $unwin
d) None of the mentioned
View Answer
Explanation: $unwind operator allows for somewhat similar functionality like join, but with fields embedded within the document.
5. Point out the wrong statement.
a) CURRENT references the start of the field path being processed in the aggregation pipeline stage
b) All stages start with CURRENT the same as ROOT
c) DESCENDING is one of the allowed results of a $let expression
d) None of the mentioned
View Answer
Explanation: However, since $<field> is equivalent to $$CURRENT.<field>, rebinding CURRENT changes the meaning of $ accesses.
6. ________ limits the number of documents in result set.
a) $project
b) $geo
c) $limit
d) None of the mentioned
View Answer
Explanation: $limit takes a positive integer that specifies the maximum number of documents to pass along.
7. Which of the following is used to retrieve like SELECT clause in SQL?
a) $reduce
b) $select
c) $project
d) None of the mentioned
View Answer
Explanation: The $project takes a document that can specify the inclusion of fields, the suppression of the _id field, the addition of new fields, and the resetting the values of existing fields.
8. _______ groups documents by some specified expression and outputs to the next stage a document for each distinct grouping.
a) $setcon
b) $group
c) $match
d) None of the mentioned
View Answer
Explanation: $group works similar to group by clause in SQL.
9. ____________ works similar to HAVING clause in SQL.
a) $setcon
b) $group
c) $match
d) None of the mentioned
View Answer
Explanation: Place the $match as early in the aggregation pipeline as possible.
10. COUNT function is provided by _________ in MongoDB.
a) $end
b) $sum
c) $max
d) All of the mentioned
View Answer
Explanation: $sum ignores non-numeric values just like SQL.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Practice Programming MCQs
- Check Information Technology Books
- Check MongoDB Books
- Apply for Programming Internship