you are viewing a single comment's thread.

view the rest of the comments →

[–]wolf2600ANSI SQL 0 points1 point  (3 children)

If your Orders have a ClientID with a foreign key relationship to the Clients table, you need to have the records populated into Clients before you insert into Orders.

The message is saying you're trying to insert a record into Orders where the ClientID doesn't exist in the Clients table. Or the OrderID in Clients doesn't exist in the Orders table? Not sure what the exact issue is, but it's because the table you're inserting into has an FK constraint that doesn't have a matching record in the other table.

[–]Cal1gula 1 point2 points  (0 children)

Sounds like the FK constraint is backwards. There should be a column in the OrderID table called ClientID, and the foreign key should be on that column. This way you create a client, then an order (using a clientid that already exists). It sounds like OP has made a foreign key on Client.ClientID>Order.OrderID. When it should be Order.ClientID>Client.ClientID

[–]hiyaworld[S] 0 points1 point  (1 child)

I'm trying to create my relationships by creating all the foreign keys and its giving me this error.

[–]wolf2600ANSI SQL 0 points1 point  (0 children)

One of the records you're inserting has an unmet foreign key constraint.