I have 2 tables a parent and child table when I remove the parents' records, Should not be deleted so I do not use it on deleted cascades. And I also do not want to use foreign keys at all because I can not even remove the records of parents until any child records are referenced. There is no substitute for FKey to make faucet eligible for having an alternative relationship because children can be present only when there is a related parent.
OK FKey has been completely removed, there is no connection between those 2 tables in my unit relationship diagram, but this is not true.
Now what will you do
- The key to the parent when you remove the original lines in the child's table.
- When you delete the original lines, place the parent key in the child's table.
In the first case, use the DELETE SET NULL on a foreign key and
to do so (your DBMS believes that supports the hurdle .)
In the second case, do not use any foreign key constraints.
Your need does not have to mean for a non-empty foreign key. On the one hand, you say that children should be in existence only when there is a relative parent. On the other hand, you want to remove the parents without removing the children. Those two requirements will not play well together.
Believing that you sometimes want to delete the original lines (not just flag them) without removing hair lines.
Comments
Post a Comment