Reputation: 161
I do have a sql table where Table B has a one-to-many foreign key relationship with table A id. I do not want the table B records to be deleted if table A relative parent record is deleted. I have tried CASCADE and NO ACTION at delete & update but nothing gives a solution other than removing the foreign key constraint. Is there another way I can have a work around without removing the constraint?
Upvotes: 1
Views: 1190
Reputation: 40481
I didn't hear of any way to have a foreign key constraint and keep the record on the child table after it was deleted from the parent table. Thats why its called constraint, its a rule that cannot be broken.
I can suggest another thing, instead of deleting the record, make it unavailable. Add a date field or an indication feild, that will tell you this record is out of order.
Upvotes: 2