Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

Mongodb Model Tree Structures. What pattern should i choose?

I need to model a huge binary tree considering:

*Need to know if a node is left child or right child

*The binary tree can grow indefinitely

*Updating structure is not possible, It is only allowed to add a new nodes

*Find specific descendant node by numer and direction (left or right)

*Find last descendant by direction (left or right)

I was reviewing the proposed pattenrs by mongodb:

°Materialized Paths : https://docs.mongodb.com/manual/tutorial/model-tree-structures-with-materialized-paths/

°Child References: https://docs.mongodb.com/manual/tutorial/model-tree-structures-with-child-references/

I was thinking for my case is better use Materialized Paths but I was worried about the storage of the path because of its lenght (grow indefinitely). In the other hand there is Child References pattern, it is good but I was worried about finding the whole path of a node talking about the performance of the traversal operation.

Thats it, which one would you recommendme?, What other ways do you think there are to model this situation?. Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...