MongoDB Questions and Answers – Model Tree Structures

«
»

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

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

Answer: a
Explanation: You can create an index on the field to enable fast search by the parent node.

advertisement

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

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

Answer: a
Explanation: In addition to the tree node, document stores in an array the id(s) of the node’s children.

advertisement
advertisement

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

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

Answer: a
Explanation: Node may have multiple parents for Child Parents.

advertisement

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

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

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

advertisement

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

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

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

advertisement

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Reference Books in MongoDB.

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!
advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter