Blockquote
Quassnoi said :
You should use either nested sets or parent-child models.
Blockquote
I used to implement both of them. What I could say is :
use the nested set architecture if your categories table doesn't change often because on a select clause it's fast and with only one request you can get the whole branch of the hierarchy for a given entry but on a insert or update clause it takes more time than a parent child model to update the left and right (or lower and upper in the example below) fields.
Another point, quite trivial I must admit, but...
It's very difficult to change the hierarchy by hand directly in the database (It could happen during the dev level). So, be sure to implement first an interface to play with the nested set (changing parent node, move a branch node, deleting a node or the whole branch etc..)
Here are two links on the sub ject :
www.sitepoint.com/article/hierarchical-data-database/
dev.mysql.com/tech-resources/articles/hierarchical-data.html
I'm new here, so I can't create hyperlinks
Last thing, I didn't try it, but I read somewhere that you can have more than one tree in a nested set table, I mean several roots.
Bye
Fred