Link to home
Start Free TrialLog in
Avatar of appbuilder
appbuilder

asked on

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tbl_ticket_tbl_location".

Greeting everyone.

I cant seem to find my way through this issue.

I have 2 tables in my dbase that are related:

tbl_ticket (fk)
tbl_location(pk)

These tables are related by locationID

Some companies my dbase have multiple locations others dont!  So when i run an INSERT query the companies with multiple locations work fine. But, when i try to run the INSERT query from a company with no locations i get the following error message:


The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tbl_ticket_tbl_location".  

What would you suggest i do in this instance...?

I presume im trying to insert and ticket and not associating a location to the newly created ticket but for the company with no location NONE exist. What should i do to work around this?
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of appbuilder
appbuilder

ASKER

If i remove the foreign key constraint, what will happen to the rest of my records in the dbase?
Do i really need foreign key constraints in the first place?
Thanks !
appbuilder,

FK as for implementing Referential integrity:)


Aneesh R