开发者

Does Nested Sets model work with article with many categories (many-to-many)?

I've been using the adjacency model for hierarchical data for the longest time and was searching the internet for a more efficient way to traverse trees until I read about Nested Sets yesterday. I liked the idea but have a few doubts.............

Now I just wanted to know if it is possible to use the Nested Sets model for many-to-many relationships. e.g. for articles to belong to multiple categ开发者_如何学Goories.

I have done some research on the internet and couldn't find any meaningful conclusion to this burning question so I would really appreciate it if you guys can shed a light on this.

Thanks in advance!


Assuming your categories have the parent-child hieararchy, yes.

You could make the categories table a nestedset, and then you'd link articles from a separate table with foreign keys to the categories.

This is of course assuming the same category cannot be a child of more than one parent category.

If a category can be a child of more than one parent, then nested set won't work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜