Table Structure For Shopping Cart

They have: 157 posts

Joined: Mar 2002

I'm looking for some ideas on how to structure my database tables for my shopping cart with respect to multiple categories for any one product.
And how about if a poduct can belong to more than one category. As in - auto>car>4door>red>stereos>jvc4000 - just an example. And this jvc4000 could also belong to blue.
Any ideas would be appreciated. I can do like a product in a subcategory under a top category, but any deeper and I'm at a lost. How should the relationships be done, etc... I guess I'm looking for an easier way to do it than I think I'd have to, or is it really as hard as I would imagine?

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

A setup like this should work or at least point you in the right direction:

Cars
----
CarID
CarTypeID (link to CarTypeID in CarType)
ColorID (link to ColorID in Color)
AccessoryID (link to AccessoryID in Accessory)

CarType (2 door, 4 door etc)
-------
CarTypeID
CarType

Color (blue, red etc)
-----
ColorID
Color

Accessory (stereo model)
---------
AccessoryID
Accessory

PJ | Are we there yet?
pjboettcher.com

They have: 13 posts

Joined: Apr 2002

I think you are trying to make one element (category) do too many things.

An item has many aspects to it. Category, Color, Size, Weight (for shipping), partners (when you sell a printer suggest a printer cable to customer), yada yada. Just add more field,s and clean up your category concept. You can always do multilevel reporting (summary or detail) later based on multiple columns in a query.

I hope this helps.

Visit my portal project -temporarily at http://www.bobcosta.com/bcportal

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.