If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Shopping carts, product tables and database relations

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-06, 14:16
marsvin marsvin is offline
Registered User
 
Join Date: Oct 2006
Posts: 2
Question Shopping carts, product tables and database relations

Hi All,

I have a simple web app with a shopping cart type system. I have one table holding all product details (ie. productname, description, price, etc.), another which lists order items (this one contains product_id, order_id) and finally the order table itself (holding date, user_id, payment details, order status, etc.)

This setup makes it easy to query the order list and get details for the products related to the order and makes it easy to assign as many items to each order as I want.

Now the problem, I need to add a second type of product to the database with very different product details. I can't put the new products in the existing product table. But putting them in a new table would make it impossible to link them to an order in the current setup.

Would my best bet be to strip the product details from the product table itself and move them to another relational table so I can use the basic product table for everything?

Hope I haven't made this sound too confusing, any thoughts would be greatly appreciated

-- marsvin
Reply With Quote
  #2 (permalink)  
Old 10-29-06, 11:54
marsvin marsvin is offline
Registered User
 
Join Date: Oct 2006
Posts: 2
Exclamation

Maybe I didn't explain quite right or maybe it was too much of a newbie thing to answer but an Single Table Inheritance relation was the answer here.. Just thought I'd post it here for future generations
Reply With Quote
  #3 (permalink)  
Old 10-29-06, 12:19
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
by no means is this "too much of a newbie thing"

do a search for subtype/supertype to see how difficult it is to design for dogmatically

could you explain where you heard the term "Single Table Inheritance relation" please?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On