Welcome Guest, Not a member yet? Register   Sign In
Category Tree (Ulimited Sub Categories)
#1

[eluser]bennyhill[/eluser]
I searched the web but couldn't find a concise answer. Has anyone implemented an application that has a category tree where a category can branch and have children? I'm making a product catalog. I need to know how to set up the database tables to support this, and also a recursive function that will query the database.
#2

[eluser]dmorin[/eluser]
Check out: http://dev.mysql.com/tech-resources/arti...-data.html. It's not really mysql specific so don't worry if you're using something else. Basically, there are two main kinds of trees, Adjacency List Model and Nested Set Model. Adjacency is easier to setup and manage but you can't easily query for an entire branch without first knowing the max number of levels. Nested Set is a bit more complex when you're first starting, but ends up being a bit more powerful in that you can return a single branch (or more) with a single query regardless of how many levels it has.
#3

[eluser]bennyhill[/eluser]
That's crazy that you mentioned that article because I am currently reading it! Looks promising Thanks.
#4

[eluser]Mischievous[/eluser]
Umm... there are several forum posts about this same thing on this forum? Try running a search for it on here. Also, you don't really want to run a recursive function on the database (could turn out to be a huge resource cruncher) if at all possible try cutting down the query to 1 that pulls the entire list. Will be back on in a bit with some code samples/database structures if your search still comes up with nothing.




Theme © iAndrew 2016 - Forum software by © MyBB