Solved

Database schema for Product Subcategories, Colors, & Sizes

Posted on 2009-06-29
8
1,371 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Trouble connecting to SqlServer database 4 49
Remote Server returned '400 4.4.7 Message delayed' 3 78
Insert data into database 2 36
Powershell script 13 60
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…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

911 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

23 Experts available now in Live!

Get 1:1 Help Now