Hello dudes!
First, I want to apologize for my Engrish, it's not my native language.
So, I am working on a webstore for shoes. I am wondering in what way I can setup a MySQL table where the quantity of the different sizes can be stored?
Any tips and instructions are greatly appreciated!
Thanks in advance, The PHP & MySQL newbie.
Shoe Store Setup
Moderator: General Moderators
- mecha_godzilla
- Forum Contributor
- Posts: 375
- Joined: Wed Apr 14, 2010 4:45 pm
- Location: UK
Re: Shoe Store Setup
I think you'd probably want to have three tables to do this, one for each distinct product type (products), one for the type of shoe (shoe_type) and another for the size (shoe_size).
Your tables might look like:
products
product_id: 1
product_code: MENS-0001
shoe_type: 1
shoe_size: 1
quantity: 10
shoe_type
shoe_id: 1
shoe_description: Comfortable men's work shoe
shoe_size
size_id: 1
size_description_uk: 8
size_description_us: 9
size_description_europe: 42
To retrieve the values, you'd then need to use JOIN - an example SQL statement (not checked for errors!) might be:
Hope that helps,
Mecha Godzilla
Your tables might look like:
products
product_id: 1
product_code: MENS-0001
shoe_type: 1
shoe_size: 1
quantity: 10
shoe_type
shoe_id: 1
shoe_description: Comfortable men's work shoe
shoe_size
size_id: 1
size_description_uk: 8
size_description_us: 9
size_description_europe: 42
To retrieve the values, you'd then need to use JOIN - an example SQL statement (not checked for errors!) might be:
Code: Select all
SELECT products.product_code, shoe_type.shoe_description, shoe_size.size_description_uk
FROM products
JOIN shoe_type ON products.shoe_type = shoe_type.shoe_id
JOIN shoe_size ON products.shoe_size = shoe_size.size_id
WHERE products.quantity > 0
Mecha Godzilla