Jump to content

Infinite categories / sub categories


ngreenwood6

Recommended Posts

I have been going in circles about how to handle the issue that I have come up with and was hoping that someone could provide a different method. Basically I want to be able to create an infinite number of categories and allow them to be assigned to other categories then making them subcategories/sub sub categories if you will. My initial plan was to use a method I have used before by just saving the parent id of the subcategories and recursively going through the data. However, I am not to fond of this because of the inefficiency that it provides. I did some research and found that method is called the "Adjacency List". I also found another way to do it called "Nested Sets" which seems to be much more efficient but its a little harder to understand / maintain. I was hoping that someone here could offer alternatives to both of these methods that will allow me to keep the efficiency of "Nested Sets" but providing the ease of use / maintenance of the "Adjacency List".

 

Thanks in advance for any help.

Link to comment
https://forums.phpfreaks.com/topic/252362-infinite-categories-sub-categories/
Share on other sites

this presentation posted by fenway in the "The MYSQL sticky" long time ago is a must to be read... around slide 48 and up apply to your case, specifically slide 68 to 77 show and explain a third alternative "Closure Table"

http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back

 

hope that help

I want to thank you again for the resource. I actually really like the closure table method. There is also alot of other good resources in that article as well. The only part that it doesn't show is how to get a full tree view in a single query which I am working on figuring out now so if you have a solution feel free to post it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.