Hierarchical Data - Nested Set Model: MySql

前端 未结 4 976
不知归路
不知归路 2020-12-16 19:18

I am just learning how to implement the Nested Set Model but still have confusion with a certain aspect of it involving items that may be part of multiple categories. Given

4条回答
  •  粉色の甜心
    2020-12-16 19:26

    Old thread, but I found a better answer to this problem.

    Since apple can have different color, your structure is a graph,not a tree. The nested set model is not the right structure for that.

    Since you mention in a comment that you're using Mysql, a better solution is to use the Open Query Graph engine (http://openquery.com/graph/doc) which is a mysql plugin that lets you create a special table where you put the relationships, basically parentId and childId. The magic is that you query this table with a special column latch depending of the value passed in the query will tell the OQGRAPH engine which command to execute. See the docs for details.

提交回复
热议问题