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 > Design Dilemma - Rows or Columns ??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-17-04, 01:27
heals1ic heals1ic is offline
Registered User
 
Join Date: Sep 2004
Posts: 2
Design Dilemma - Rows or Columns ??

Here is my design dilemma:

I have a table that contains products for each supplier.

| supplierid | prodid | price_each | price_case |

This means that for every new supplier I add, I have to add records for all the products available to this table. I intend to have around 10 suppliers and probably around 500 products, so around 5000 records for option 1.

The other option is to have this table structure:

| productid | Supplier1_price_each | Supplier1_price_case | Supplier2_price_each | Supplier2_price_case | Supplier........ and so on till nth supplier.

This means 500 products but 2 columns for each supplier.

Which is better for both performance and design?

The first option has more overheads that have to be covered in my php code to produce the extra rows to accommadate the new supplier as it is added.

The second option only requires me to add 2 columns every time a new supplier is added.

Not sure which otion is best.
Reply With Quote
  #2 (permalink)  
Old 09-17-04, 05:16
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by heals1ic
Which is better for both performance and design?
the first, hands down

example 1: what happens in each design if you stop doing business with supplier 127?

example 2: how do you count in each design how many suppliers supply product X?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 09-17-04, 08:10
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Agreed with Rudy 100% (of course). You should get yourself a book on relational database design and look up "repeating groups".

But I'm intrigued: how could adding 2 new columns to the table for a new supplier not have any impact on your php code?
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
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