Link to home
Start Free TrialLog in
Avatar of Escanaba
EscanabaFlag 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
Avatar of slightwv (䄆 Netminder)
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.
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.
Avatar of 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.
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Really appreciate the detailed explanation (and patience).  This was very helpful.  Thank you!!
Good luck!  Feel free to post questions as you run across them.  We're here to help.