I want to insert data and realize order operation from user input data. I created this tables:
Order
|OrderID - PK|CustomerID - FK|OrderDate|
OrderDetails
|OrderID - PK,FK|ProductID - PK,FK|Quantity|
Customer
|CustomerID - PK|FirstName|LastName|Address|
Product
|ProductID - PK| |SuplierID - FK| |Quantity|
Supplier
|SupplierID - PK|Name|
I want to use stored procedure to insert data, but I've problem with construct t-sql.
if i understand the question correctly, you want to know which order to insert data into tables to ensure no violations, is that correct?
From your post it looks like you insert in this order:
Quantity column would be on the OrderDetail table, as you can have more than one of each line item.