User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Database Design section within the Web Development category of DaniWeb, a massive community of 391,582 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,683 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Database Design advertiser:
Views: 765 | Replies: 1
Reply
Join Date: Jan 2008
Posts: 1
Reputation: shapeshifterx is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
shapeshifterx shapeshifterx is offline Offline
Newbie Poster

E-commerce product variations

  #1  
Jan 10th, 2008
I am currently designing the product/product variation tables for my e-commerce site.

my tables so far are as follows (ive taken columns that arent related to the problem out).

PRODUCT(prod_id*, name, desc, price) //product details
VARIATION(var_id*, name) //colour, weight, strength etc
VARIATIONS(vars_id*, name) //blue, green, 100g, 200g, 5x etc.
PRODUCT_VARIATION(prod_var_id*, prod_id, var_id)
PRODUCT_VARIATION_CHOICES(prod_var_id, vars_id)

this seems like alot of tables for the job

what i need to do is have products that can have two variations, for instance:

selling chocolate, variation 1 is weight, variation 2 is colour. there are two different weights. 100g and 200g. 3 different colours, white, milk, dark.
you can buy all colours at 100g, but only milk at 200g.

the way i can see this in a database is, having two PRODUCT_VARIATION_CHIOCES tables, one primary the other secondary. With the secondary holding the key of the primary.

So primary is colour, secondary is weight.

PRODUCT_VARIATION_CHOICES_PRI(prim_id*, prod_var_id, vars_id)
PRODUCT_VARIATION_CHOICES_SEC(prim_id, prod_var_id, vars_id)

I think there are two many tables, and it gets tricky when working out the price. would the price be in the PRI and SEC tables?

Any help is greatly appreciated.

Thank you,
Andrew
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Location: London, England
Posts: 57
Reputation: hooray is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
hooray hooray is offline Offline
Junior Poster in Training

Solution Re: E-commerce product variations

  #2  
Jan 17th, 2008
Originally Posted by shapeshifterx View Post
I am currently designing the product/product variation tables for my e-commerce site.

my tables so far are as follows (ive taken columns that arent related to the problem out).

PRODUCT(prod_id*, name, desc, price) //product details
VARIATION(var_id*, name) //colour, weight, strength etc
VARIATIONS(vars_id*, name) //blue, green, 100g, 200g, 5x etc.
PRODUCT_VARIATION(prod_var_id*, prod_id, var_id)
PRODUCT_VARIATION_CHOICES(prod_var_id, vars_id)

this seems like alot of tables for the job

what i need to do is have products that can have two variations, for instance:

selling chocolate, variation 1 is weight, variation 2 is colour. there are two different weights. 100g and 200g. 3 different colours, white, milk, dark.
you can buy all colours at 100g, but only milk at 200g.

the way i can see this in a database is, having two PRODUCT_VARIATION_CHIOCES tables, one primary the other secondary. With the secondary holding the key of the primary.

So primary is colour, secondary is weight.

PRODUCT_VARIATION_CHOICES_PRI(prim_id*, prod_var_id, vars_id)
PRODUCT_VARIATION_CHOICES_SEC(prim_id, prod_var_id, vars_id)

I think there are two many tables, and it gets tricky when working out the price. would the price be in the PRI and SEC tables?

Any help is greatly appreciated.

Thank you,
Andrew


Ok I can see two ways to go with this, both with only 3 tables;
the first would be to simplify what you have:
PRODUCT(product_ID*, name, desc)
VARIATION(var_ID*, colour, weight, strength, price) // and any others
PRODUCT_VARIATION(provar_ID*, product_ID, var_ID)

going with your example of chocolate, this would mean an entry into the variation table for each variation, so
VARIATION("1001, white, 100g, 5x, £3" "1002, white, 200g, 5x, £5")

the other way, all i have done is simplified further:
PRODUCT(product_ID*, name, desc)
VARIATION(var_ID*, variation, value)
PRODUCT_VARIATION(provar_ID*, product_ID, var_ID)

so the variation table would include these kind of entries:
VARIATION("1001, colour, white" "1002, weight, 100g" "1003, colour, dark")
this is a simpler method in the short term, I personally favour this way, since I try to have as few variables in each table as i can.

I hope this is helpful to you.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Database Design Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Database Design Forum

All times are GMT -4. The time now is 10:54 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC