Part Database - Network Model / Hierachal Model / Nested Sets / Acyclic Graphs. Which is right here?

扶醉桌前 提交于 2020-01-05 15:36:11

问题


We are using PHP / SQL to build a parts database which will output as a tree structure. After plunging head first into the coding with the nested sets model we realised that we needed to adjust the model to allow for multiple parents.

Effectively, every child can have more than one parent, and every parent can have more than one child, but each node cannot be its own relative. We want to link a collection of parts (A) to a parent part and create a larger part (B) whilst keeping the original collection (A) in isolation. That part collection (A) could be used in another part tree but any change to part collection (A) would adjust all entitities it exists within.

We modified the nested model with dependency links similar to the adjacency model and an unique tree id for each part which allows for the individual trees to build up from that.

This worked perfectly to link parts but when it came to unlinking parts there were problems. Part E could be part of Part D and Part C. When Part C is linked to Part B there is no unique route to Part E without traversal which becomes more extensive the larger the tree gets.

Is there a model which is best suited to a parts database such as this? We have looked at the methods in the question title and the potential to hybrid these models but it is not immediately clear which method or combination will suit this purpose.

Any input greatly appreciated. Thanks.

来源:https://stackoverflow.com/questions/12174331/part-database-network-model-hierachal-model-nested-sets-acyclic-graphs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!