phpsycho Posted September 15, 2011 Share Posted September 15, 2011 What would be the best way to do categories and multiple sub categories for a eCommerce website? For example there could be... Website templates => Flash => Portal => Music Computer hardware => Gadgets => USB => Fun Scripts => PHP => eCommerce => Simple Scripts => Perl => Search engine => Simple So something like that.. how should the database structure look? Also say I have a table called 'products' and a column called 'cat'.. if the best idea would be to create `categories` `sub1_cat` `sub2_cat` etc for tables then should I put each id of the categories into the column 'cat' and separate by comma? Then like explode that column when I need to grab each category or whatever? I dunno... lol very confusing, I just can't wrap my head around it. Link to comment https://forums.phpfreaks.com/topic/247229-table-categories/ Share on other sites More sharing options...
phpsycho Posted September 16, 2011 Author Share Posted September 16, 2011 Like I said.. I could just create like 5 tables (subcat1,subcat2,subcat3, etc) and then just add each id from each of those tables to the product table column `cat` and when needed I could explode or something.. dunno how I'd pull specific products from each sub category though using a sql query. Theres gotta be a better way... I just can't seem to find it. Link to comment https://forums.phpfreaks.com/topic/247229-table-categories/#findComment-1269736 Share on other sites More sharing options...
fenway Posted September 16, 2011 Share Posted September 16, 2011 I like nested sets -- but they're slightly annoying to maintain (parent, depth, ancestor, etc.). Link to comment https://forums.phpfreaks.com/topic/247229-table-categories/#findComment-1269739 Share on other sites More sharing options...
phpsycho Posted September 16, 2011 Author Share Posted September 16, 2011 Could you give an example? Sorry lol I feel dumb, but I don't really know what you mean by a nested set. hmmm any other ideas then maybe? I'm looking for the most simple, but works perfectly. I suppose I could use a pain in the ass method if I had to, but yeah.. rather not lol. Link to comment https://forums.phpfreaks.com/topic/247229-table-categories/#findComment-1269749 Share on other sites More sharing options...
fenway Posted September 16, 2011 Share Posted September 16, 2011 Closure tables are a less painful option. Link to comment https://forums.phpfreaks.com/topic/247229-table-categories/#findComment-1270110 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.