Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
multiple options to a product stored as a record?
Old 01-15-2007, 03:45 PM multiple options to a product stored as a record?
Average Talker

Posts: 27
Trades: 0
I am currently playing with a database which has a table in it that stores products which consists of a product id, product name and product description.

However, some of the products may have options within themselves. If for example, a product which is a Jacket is available in small at £10, medium at £12 or large at £14, rather than creating a new record for each of the 3 possiblities, is there any way that there need only be one record for the jacket, and then the 3 options with their prices stored seperately in the database?

I realise there is the possibility of storing the 3 options in another table and referencing that. But there may be other products with totally different options that are not like size but may be colours for example.

Would another table need to be created for a different product options if that were the case?

example: (I would like the below stored as 2 records in the products table with all options available to be called - a drop down menu for the options in the shoppers interface would be good - rather than 6 different records)

Product name Option Price
Men's Jacket Small £10
Men's Jacket Medium £12
Men's Jacket Large £14
Men's Hat Red £5
Men's Hat Blue £5
Men's Hat Gold £7

Generally, what would be the best way to design the table structure and implement all this?

Thanks
gavrd1 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-16-2007, 03:26 AM Re: multiple options to a product stored as a record?
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
Quote:
Originally Posted by gavrd1 View Post
rather than creating a new record for each of the 3 possiblities, is there any way that there need only be one record for the jacket, and then the 3 options with their prices stored seperately in the database?

It's possible, but you really don't want to. At some point, there'll be a product with four options, then you're SOL. So you could set it up with four options from the get go, but eventually you'll need five. You can see where I'm going with this.

What you probably want to do is create a second table, for ONE option, with the price, what makes it unique, and the ID of the product it falls under. And then allow a one-to-many relationship between these two tables. With this approach, you can pull a type of product out of the main table, and then easily drill down to sub-products that have the same ID and give a list of them, whether it's 3 or 30.

There are other options, but that's probably the best, all around.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Reply     « Reply to multiple options to a product stored as a record?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16020 seconds with 12 queries