I am thinking of what the best way is to store a given menu tree for a shop-like system. That includes a menu tree with multiple sub-levels and items that are assigned to those levels.
Special requirements: - Each level needs to include all items of the sub- and sub-n-levels - Each item (might!) be assigned to multiple levels
Short example:
[Category A]
[Category A-A]
- Product: Apple
[Category A-A-A]
- Product: Pear
[Category B]
- Product: Salad
- Product: Apple
Following ouputs: - Display root: The tree + all products shall be shown (1x Apple !, Pear and Salad) - Display Category A-A: The tree + Apple and Pear shall be shown - Display Category A-A-A: The tree + only Pear shall be shown
Any suggestions or hints to achieve that with help of PHP and MySQL?
Have a look at:
http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/
and
http://en.wikipedia.org/wiki/Nested_set_model
(for a first reading)