I think the best solution would be TABLE ITEMS [ item_id | parent_id | item_name ]
data 1, 0, foo 2, 0, bar 3, 2, baz 4, 2, quux 5, 1, fee 6, 1, fi So above baz and quux are subcats of bar and fee/fi are subcats of foo This structure allows for unlimited levels of sub-categories to be added. Getting items for a 'browse' category feature is as simple ass selecting all items where parent_id = 'whatever' Using a recursive loop you can build a tree structure olinux --- Wellington Fan <[EMAIL PROTECTED]> wrote: > Hello all, > > I have an 'items' table with 2 'types' of items -- > 'foo' & 'bar' > > Say that items of type 'bar' may be further > classified as 'subtypes' 'baz', > 'quux', etc. > > Now I build an online store so that visitors may buy > items. > > Contstraints > 1.) I would like to, as much as possible, use the > same code for ordering > 'foo'-items and 'bar'-items. > 2.) If a user orders a 'bar'-item, they MUST specify > a subtype. I.e. -- one > may buy a 'bar-baz', or a 'bar-quux', but NEVER a > 'bar'. > > My questions are these: > 1.) Does it make more more sense to split the > 'items' table into a 'foos' > table and a 'bars' table? This means I will often > have to recombine them > using more than one query: > select * from foos where foos.id in (shoppingcart) > + > select * from bars where bars.id in (shoppingcart) > > 2.) If I DON'T split into 2 tables, I must then keep > the '#inStock' in both > the 'items' table (for 'foo'-items) and in the > 'subtypes' table (for > 'bar'-items). This doesn't feel right. Any > suggestions? > > > Thanks, all! > > -- > WF > > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list > archive) > > To request this thread, e-mail > <[EMAIL PROTECTED]> > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: > http://lists.mysql.com/php/unsubscribe.php > __________________________________________________ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/ --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php