I have a question regarding SQL. I have the following SQL tables (Simplified for easy comprehension):
Client(clientId INT PRIMARY KEY)
Product (productId PRIMARY KEY)
Order (orderId PRIMARY, clientId which is foreign key to Client, productId which is foreign key to Product)
I also have a table called Inventory, which is supposed to contain the number of items in stock for each product. The primary key to Inventory is called productId (Primary Key), which references the foreign key in Order. Unfortunately, when I try to add to the Inventory table, it gives me the following error:
"The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Order_Iventory1". The conflict occurred in database "GestionInventaire", table "dbo.Inventory", column 'productId'."
I want the Inventory tables primary ID (productId) to be the foreign key in Order (productId), which comes from the Product table.
Any help is appreciated! If any further explanation is required I will try to elaborate further.