![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
are there any complications in general with a many-to-many "join table" having cascading deletes on both foreign keys to the interconnected tables?After all, this means that the "link entities" get deleted whoever comes first... could this pose a problem? |
#3
| |||
| |||
|
|
Hello, are there any complications in general with a many-to-many "join table" having cascading deletes on both foreign keys to the interconnected tables? After all, this means that the "link entities" get deleted whoever comes first... could this pose a problem? I cannot think of any concrete examples where this could really do harm, but if there are, please enlighten me. Karsten |
#4
| |||
| |||
|
|
are there any complications in general with a many-to-many "join table" having cascading deletes on both foreign keys to the interconnected tables? After all, this means that the "link entities" get deleted whoever comesfirst... could this pose a problem? The ANSI/ISO *model is that first you mark all the rows in all the tables with a delete flag. If no constraints are violated, then a second pass does the actual removal. If a constaint is violated at any point, then the engine does a rollback and sends an exception. The multiple passes can be expensive, but they are safe. |
#5
| |||
| |||
|
|
On 20 jun, 15:35, -CELKO- <jcelko... (AT) earthlink (DOT) net> wrote: are there any complications in general with a many-to-many "join table" having cascading deletes on both foreign keys to the interconnected tables? After all, this means that the "link entities" get deleted whoever comes first... could this pose a problem? The ANSI/ISO model is that first you mark all the rows in all the tables with a delete flag. If no constraints are violated, then a second pass does the actual removal. If a constaint is violated at any point, then the engine does a rollback and sends an exception. The multiple passes can be expensive, but they are safe. Is the SQL standards crew now also prescribing how implementations should be done ? |
#6
| |||
| |||
|
|
The concept of "cascade delete" is pretty well understood and pretty well-defined, and if some DBMS chooses to support it, it is that DBMS's responsibility to do so properly. That is, it is the responsibility of that DBMS's authors to see to it that their implementation does not cause any "problems". If it did, their implementation would be flawed. |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
Some of these cycle problems are known to be ambigous or NP-complete. Add in deferred constraints and it is a real mess. The safety rule is to keep the cascades paths as trees -- no cycles. |
#9
| |||
| |||
|
|
The only thing I had the impression the OP was talking of was a junction table J between R1 and R2, with a cascade delete rule from R1 to J, as well as from R2 to J. |
|
While of course I recognise that cycles hold the danger of infinite recursion when processing them, isn't your assertion too strong? |
![]() |
| Thread Tools | |
| Display Modes | |
| |