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. 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. 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. 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
Archived
This topic is now archived and is closed to further replies.