Jump to content

[SOLVED] table structure for ecommerce product data


bcamp1973

Recommended Posts

i'm building a modest ecommerce platform and I'm having trouble deciding how best to store product information. The site will sell various types of product so it needs to be flexible.  My problem is this.  There will be various product categories and subcategories.  For examples "Shoes" will be a parent, and its children might be "Sandals", "Dress Shoes", "Sneakers" etc. Then another category might be "Shirts" etc.  However, based on the category the products will have different data.  For shoes, sizes will be something like 7-16, Shirts will be S,M,L,XL etc. Shoes will also have widths.  Some products will have different material composition to choose from (Leather/canvas etc.).  Has anyone successfully modeled this in such a way that isn't a sloppy performance hog or a rat's nest of tables?  ::)  I just want to do this right the first time and my googling isn't getting me any good examples  :-[

Link to comment
Share on other sites

My tables would probably look something like this:

- categories (id, parent_id, description, sort_order)

- items (id, cat_id, description, size_id, material_id, color_id, ...)

- sizes

- inventory

 

Using that approach you can comfortably nest categories 3 levels deep. (Shirts->Dress->Long Sleeve). If you feel you need to go more than 3 levels deep, then I'd suggest a different approach. But I kinda doubt you'll need to.

Link to comment
Share on other sites

Thanks artacus!  I think that clarifies a couple things for me. Looking at it this morning after a nights sleep doesn't hurt either ;) Your reply raises a couple questions for me tho. For one, inventory...my initial thought was to have a "quantity" file in the item table.  Your suggestion makes me think i'm not quite thinking it through enough.  Also, if i wanted to go more than three levels deep (possible but not sure at this point) how might you approach that?

Link to comment
Share on other sites

Well the queries for going much deeper than 3 levels gets unruly. So then you switch to the nested tree approach.

 

There was a great tutorial for doing this in PHP at phpriot.com. The link isn't working for me at the moment. Maybe the server is just having problems...

 

http://www.phpriot.com/d/articles/php/application-design/nested-trees-2/index.html

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.