MySQL table structure question
I've been looking around on SO and have been seeing a lot of questions about category tree menus and was wondering how would my MySQL table or tables look like so I can add many ca开发者_开发知识库tegories and count less sub categories and display them on my web site.
Note I will be using PHP & MySQL.
I usually use a structure similar to the one below:
Category
--------
CategoryId
CategoryName
ParentCategoryId
MySQL has a decent article on this subject, Managing Hierarchical Data in MySQL, if you are interested in doing some more research on the subject. It goes into this structure and gives you some sample queries on how to get the data you want for specific scenarios.
精彩评论