Escanaba
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
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
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.
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.