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.
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.
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.