djones Posted November 13, 2007 Share Posted November 13, 2007 Whats the best way to store categories and sub categories in MySQL for a specific product item? Should I store them inline with the item or should I create a new table that has the categories with the product ID? I guess what I getting at is when I query the product table, should I have the categories in that table too or query a separate table that has the categories and the associated product ID? There will be a main category and 2 sub categories. Quote Link to comment https://forums.phpfreaks.com/topic/77145-solved-categories-and-sub-categories/ Share on other sites More sharing options...
cmgmyr Posted November 13, 2007 Share Posted November 13, 2007 Here is the best way to do this: products ======== id name cat_id ect... categories ======== id parentid name This is the easiest and most efficient way to work with categories. Quote Link to comment https://forums.phpfreaks.com/topic/77145-solved-categories-and-sub-categories/#findComment-390620 Share on other sites More sharing options...
djones Posted November 13, 2007 Author Share Posted November 13, 2007 ok, reference the cat_id. Sounds good to me. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/77145-solved-categories-and-sub-categories/#findComment-390629 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.