How to design a database which has single category and n number of sub categories using mysql
Example:
category
catId categoryName
1 cat 1
2 cat 2
3 cat 3
4 cat 4
subcategory
subCatId subCategoryName catId
1 subcat1 1
2 subcat2 1
3 subcat3 2
4 subcat4 4
For single category i can the above structure.
Like this if i am having n number of subcategories. In this case how should i design the db
thanks in advance
You could use just one table
categorywith columns:category_idcategory_nameparent_category_idFor main categories You set
parent_category_idto null and You’re done. 🙂