Solved

Database schema for Product Subcategories, Colors, & Sizes

Posted on 2009-06-29
8
1,350 Views
Last Modified: 2013-12-16
Hello,

I have a general working knowledge of mySQL and I'm developing an e-commerce application using Coldfusion.

Before I dive into the client side, I want to make sure my database schema is properly in place.

Can anyone show me the most efficient way to set up my database to allow for product Subcategories, colors, and sizes? (I'm selling T-shirts).

A few things to know:

>>Subcategories - I want my users to be able to find items under multiple subcategory searches (i.e. Long-sleeve Pocket T-shirts can be found under "T-shirts>>Longsleeve", "T-shirts>>Pocket", "T-shirts>>Longsleeve>>Pocket", or "T-shirts>>pocket>>longsleeve" respectively.  Many subcategory examples I've seen only allow one subcategory per product, which is not what i want.

>>Colors & Sizes - My items don't come in all colors.  most of my items have a range of colors unique to that item number, so I need to only show colors on that item that are actually available in that item.  the same goes for sizes, not all products come in every size.

Any help on how the schema should look for this portion of my database would be appreciated, including an Entity Relationship diagram would help, too.

Thank you for your help.  :)
0
Comment
Question by:chaseivey
  • 3
  • 3
8 Comments
 
LVL 41

Expert Comment

by:pcelba
ID: 24738207
You should create following tables (the first column is PK, other columns are FKs or descriptive columns):

MasterItem - MasterItemId, MasterItemCode, Descr, ...  (will contain T-shirt, shoe, car, space shuttle, ...)
Subcategory  - SubcategoryId, SubcategoryCode, Descr, ...
Color  -  ColorId, ColorCode, Descr, ...
Size  - SizeId, SizeCode, Descr, Metric (Y/N), ...
Item - ItemId, ItemCode, Descr, MasterItemId, SubcategoryId, ColorId, SizeId, ValidityRange, ...
UoM - UoMId, UoMCode, Descr, ...
UoMConversion - UoMcID, MasterItemId, UoMID1, UoMID2, koef
Stock - ItemId, Quantity, UoM, LocationId, ...

You can define more tables for Item categorization, e.g. SubCat1, SubCat2, SubCat3 and use them for unspecified Item categorization.

The most efficient way depends on your needs. You have to decide how many subcategories you need, you have to decide if you need validity ranges etc.

Based on your Stock quantities you may create lists of available items. Just simple SQL Select commands... Your general knowledge should be sufficient for it.
0
 

Author Comment

by:chaseivey
ID: 24747319
Thanks for the info.  
My apologies, but it's still a little vague to me.  :(
Could you be more specific concerning exactly how these tables work with each other?  Also, I don't think I need the UOM(unit of measure) stuff (do I?).  My items are all sold individually and they are just blank T-shirts.
All that really changes is (available colors) (available sizes) (price changes based on color/size)

I figured that i only really need 3 subcategories beneath the main category(T-shirts), but i want any given item to be searchable under ANY of its subcategories.  That way i can narrow down the searches on certain pages with conditional SQL statements.

A live example of what I'm after can be found at www.cmcasuals.com.  For instance, item# PC61LSP is found under "T-shirts>>Longsleeve" OR under "T-Shirts>>Pocket" ... hmmm   maybe I only need 1 subcategory?  See what you think. :)

I may can find a simple way around this "subcategory" part, but my MAIN concern is how to accomodate the unique sizing/colors/prices changes that happen here.  You can see this when you click on any item on this site. (www.cmcasuals.com)

Thanks again for your assistance.
0
 
LVL 41

Expert Comment

by:pcelba
ID: 24749377
Tables work with each other using their primary and foreign keys. Each key column name is ended by ID and his name is beginning by the related table name. It should be sufficient enough to have everything under control. You should look for some books about data modelling (e.g. http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470178450.html)

UoM is maybe not necessary for the beginning because the only UoM is stick but you could handle boxes and palettes later :-).

What you surely need is some Pricelist table which is connected to Item (and UoM).
 
Above "data model" or its rough idea should fit almost all requirements from the mentioned web site. The main page is a picture of MasterItem table, all subpages are just results of different queries made from your tables.

If you need to display one item on several pages then you just need sufficient number of subcategories defined. You could also define "webview" subcategories and relation between Items and webview subcategory can be M:N (each item can be assigned to one or more subcategories).

So, you should first define what subcategories to distinguish on the web (and how) and then you may design data model for your data which will fullfil all your needs.

When some size/color/price change happens then you simply create new query and based on its results you have to create HTML contents. This principle is common for all data driven webs independently on the database and platform used. Its realization is, of course, different.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 39

Expert Comment

by:gdemaria
ID: 24823760
I think you should really look at the subcategories and see if you have a lot of variation.  Make a list of all the subcategories you think you will have and see if they just fall into a few types.   Instead of dealing with hierarchical subcategories, which are a royal pain, you can just have a few attributes on your table such as "sleeve Type" and "pocket type" ... life will be much easier for you that way..

Also, I assume that you want one table for your each unique T-shirt type and then a child table of that which has a list of the available sizes and colors that you sell for that shirt.   You can have the price at either the product level or the options level (if all the sizes and colors are the same price, put the price in the products table)

Products
  productID
  Name
  Description
  sleeve
  pocket
  price

ProductOptions
  prodOptionID
  productID
  size
  color
  quantityInStock
 (price?)

0
 
LVL 39

Expert Comment

by:gdemaria
ID: 24995841
well, i like my answer :)    

ID:24823760  
0
 
LVL 41

Expert Comment

by:pcelba
ID: 24996089
I like gdemaria's answer also but I would suggest point split if the question author does not decide else :-)
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 24996091
agreed
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now