This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Model Tree Structures”.
1. The ________ References pattern stores each tree node in a document; in addition to the tree node, the document stores the id of the node’s parent.
a) Child
b) Parent
c) Root
d) None of the mentioned
View Answer
Explanation: Data model that describes a tree-like structure in MongoDB documents by storing references to “parent” nodes in children nodes.
2. Point out the correct statement.
a) The query to retrieve the parent of a node is fast and straightforward
b) The query to retrieve the parent of a node is slow and straightforward
c) The query to retrieve the parent of a node is slow and complex
d) All of the mentioned
View Answer
Explanation: You can create an index on the field to enable fast search by the parent node.
3. The ________ Links pattern provides a simple solution to tree storage but requires multiple queries to retrieve subtrees.
a) Child
b) Parent
c) Root
d) All of the mentioned
View Answer
Explanation: You can query by the parent field to find its immediate children nodes.
4. The _________ References pattern stores each tree node in array the id(s) of the node’s children.
a) Child
b) Parent
c) Root
d) None of the mentioned
View Answer
Explanation: In addition to the tree node, document stores in an array the id(s) of the node’s children.
5. Point out the wrong statement.
a) You cannot query for a node in the children field to find its parent node only
b) You can query for a node in the children field to find its parent node as well as its siblings
c) You can query for a node in the children field to find its siblings only
d) None of the mentioned
View Answer
Explanation: The Child References pattern provides a suitable solution to tree storage as long as no operations on subtrees are necessary.
6. Which of the following pattern may provide a suitable solution for storing graphs?
a) Child
b) Parent
c) Root
d) None of the mentioned
View Answer
Explanation: Node may have multiple parents for Child Parents.
7. Which of the following pattern is more straightforward to use?
a) Materialized Paths
b) Array of Ancestors
c) Nested Sets
d) None of the mentioned
View Answer
Explanation: The Array of Ancestors pattern stores each tree node in a document; in addition to the tree node, document stores in an array the id(s) of the node’s ancestors or path.
8. The Array of Ancestors pattern is slightly slower than the ________________ pattern.
a) Materialized Paths
b) Array of Ancestors
c) Nested Sets
d) None of the mentioned
View Answer
Explanation: The Array of Ancestors pattern provides a fast and efficient solution to find the descendants and the ancestors of a node by creating an index on the elements of the ancestors field.
9. The ____________ pattern identifies each node in the tree as stops in a round-trip traversal of the tree.
a) Materialized Paths
b) Array of Ancestors
c) Nested Sets
d) None of the mentioned
View Answer
Explanation: The Nested Sets pattern stores each tree node in a document; in addition to the tree node, document stores the id of node’s parent, the node’s initial stop in the left field, and its return stop in the right field.
10. ____________ pattern requires additional steps of working with strings and regular expressions.
a) Materialized Paths
b) Array of Ancestors
c) Nested Sets
d) None of the mentioned
View Answer
Explanation: The Materialized Paths pattern stores each tree node in a document; in addition to the tree node, document stores as a string the id(s) of the node’s ancestors or path.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Apply for Programming Internship
- Practice Programming MCQs
- Check Information Technology Books
- Check MongoDB Books