• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1363
  • Last Modified:

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?
0
appbuilder
Asked:
appbuilder
  • 3
  • 2
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
two options
1. remove the FK constraint
2. else create a dummu entry for 'NONE'
0
 
appbuilderAuthor Commented:
If i remove the foreign key constraint, what will happen to the rest of my records in the dbase?
0
 
appbuilderAuthor Commented:
Do i really need foreign key constraints in the first place?
0
 
appbuilderAuthor Commented:
Thanks !
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
appbuilder,

FK as for implementing Referential integrity:)


Aneesh R
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now