Avatar of Escanaba
Escanaba
Flag for United States of America asked on

MS SQL Table Relationship

Hello,

I'm trying to work out a SQL problem and found myself stuck so hoping someone can assist.  Based on the attached document, I have created three tables and inserted vendors into the vendor table.  But I am not understanding how to get the data in part 3 into the vendor product table.

Would greatly appreciate any assistance as I am just learning SQL.

Thanks!
EE-SQL-Sample.docx
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
Kyle Abrahams

8/22/2022 - Mon
slightwv (䄆 Netminder)

Your vendorproduct table doesn't have a vendorname or productname column.  Therefore, you cannot insert values into them.

Since the vendorproduct table has foreign key references to the vendor and product table, you need to insert the correct rows in there first.  Once you've done that you need to insert the correct productid and vendorid values into the vendorproduct table.
Kyle Abrahams

Just to restate what Netminder set in a different way:

Ensure you have the product and the vendor inserted first.  When you insert them they will get their ids because they are set to identity.

You then insert the ids of the vendor / product into the vendor table product so you know what vendors provide which products.
Escanaba

ASKER
Kyle - Is that not what I've done by referencing the product and vendor IDs as foreign keys when I created the vendor product table?  Sorry - just really confused.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Kyle Abrahams

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Escanaba

ASKER
Really appreciate the detailed explanation (and patience).  This was very helpful.  Thank you!!
Kyle Abrahams

Good luck!  Feel free to post questions as you run across them.  We're here to help.