MongoDB Questions and Answers – SQL to Aggregation Mapping Chart

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

Answer: b
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

Answer: d
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

Answer: a
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

Answer: c
Explanation: $unwind operator allows for somewhat similar functionality like join, but with fields embedded within the document.

advertisement
advertisement

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

Answer: c
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

Answer: c
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

Answer: c
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

Answer: b
Explanation: $group works similar to group by clause in SQL.

advertisement

9. ____________ works similar to HAVING clause in SQL.
a) $setcon
b) $group
c) $match
d) None of the mentioned
View Answer

Answer: c
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

Answer: b
Explanation: $sum ignores non-numeric values just like SQL.

advertisement

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Books in MongoDB.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.