views:

65

answers:

1

Hi guys,

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 categories.

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!

+1  A: 

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.

Jani Hartikainen