February 10th, 2014, 10:20 PM
Updating columns with FK constraints
I have a table which contains a foreign key referencing another table.
By design, a record in the table stores a value in the FK column which is not represented in the other table.
I found that I could update other columns in that record without turning FK constraints off.
This kind of surprised me.
Is this to be expected future behavior, or should I disable FK constraints whenever updating such a record?
February 11th, 2014, 12:53 AM
There's no reason to disable FK constraints, especially when you're updating. The constraints are what keeps the data correct.
If I'm getting what you're saying right, you're updating columns in a table that has a foreign key, but you're not updating the column that holds the FK? If that's the case, that's exactly what it should be doing. There should be no restriction on updating a column that's not part of a FK restraint. If there was it would make things a terrible mess. It's only the column that contains the FK that you need to be concerned about, but you can still update that as long as it has a valid value in the other table.
February 11th, 2014, 04:49 AM
then it can't be an actual FOREIGN KEY
Originally Posted by NotionCommotion
if you think it is, could you please prepare a dump of some test data that demonstrates your situation