First eCommerce Site - Need advice on how to store sizes

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Mon May 16, 2011 8:36 pm

Each product will have (in addition to other fields):

Code: Select all

product_id size_id
A101        MM
A102        WXL
A103        JL
....          ....
And, when you go to the size table, you will get more info about JL, MM and WXL as:

Code: Select all

size_id   size_name    gender
MM       Medium        Male
WXL     Extra Large  Women
JL         Large         Junior
...         ....             .....

johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Tue May 17, 2011 5:15 am

Yes, provided the product id is the same.

johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Tue May 17, 2011 5:21 am

Usually one product id will have only one size because the price is based on the size and not on the product id.
So,

Code: Select all

product_id size_id price
A101         MS     $12.99
A102         WXL   $19.99
......     .... .....
You need to put all attributes on a paper and then decide how to normalize. The ideal way will be to create an entity-relationship diagram or something similar to get rid of a lot of confusion and uncertanity. Either way(whether u create a E-R diagram and then create tables or directly write the table structure) it is going to be a lot of trial and error.

johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Thu May 19, 2011 7:41 pm

I don't think that we need two size tables. Just combine size and size_info as a single 'size' table and add a size_id as a field in the product table. Also, you may need manufacturer_id as a field in the product table and a separate manufacturer table to store the details of the company that manufactured this product.

The category table is ok.

You need to read about primary key, foreign key and relationship between tables to understand how insert and select will work.

kowshika
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Oct 04, 2018 3:14 am

Fri Oct 05, 2018 4:41 am

If you are looking to develop and launch ecommerce websiteyou can create with your own ecommerce marketplace. Try to choose best ecommerce platform in succeeding ecommerce . https://goo.gl/J3eW9d

Post Reply