We help IT Professionals succeed at work.
Get Started

Is primary key mandatory?

royjayd
royjayd asked
on
1,042 Views
Last Modified: 2012-08-14
hi guys
I have a table 'supplier' with these 4 columns

supplier_id   product_id  supplier_name   cost
1                      100                   IIT                        $200
2                      100                   RAM                   $199
2                      200                  RAM                   $500
3                      500                   GAC                   $1499

I have multiple suppliers selling products but 2 different suppliers
can sell the same product,  example i have supplier_id 1 and
supplier_id 2 selling the product with product_id 100 (for a different cost)

so in this scenario what could be my primary key and what should be the
foreign key?

Do i relly need a primary key in the first place? or can i just use composite keys in this scenario?

thanks
J
Comment
Watch Question
Software Developer / Database Administrator
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 5 Answers and 16 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE