Question about MySQL table structure

I looked around SO and saw many questions about the category tree menu and wondered what my MySQL table or tables would look like, so that I could add many categories and count fewer subcategories and display them on my website.

Note. I will use PHP and MySQL.

+2
mysql
source share
1 answer

I usually use a structure similar to the one below:

Category -------- CategoryId CategoryName ParentCategoryId 

MySQL has a worthy article on this subject, Hierarchical data management in MySQL , if you are interested in doing some more research on this topic, it goes into this structure and gives you some examples of queries on how to get the data you want for certain scripting.

+3
source share

All Articles