Subject | Re: Poor selectivity in foreign keys |
---|---|
Author | johnmancuk |
Post date | 2004-10-16T10:25:51Z |
How about this scenario:
Start trans 1 (snapshot or read committed).
Start trans 2 (snapshot or read committed).
Trans 1:
Update master record (so trigger cascased changes to all child
records)
Trans 2:
Insert child record refering to original value in master (which is
still visible in this trans context)
Commit.
Trans 1:
commit.
RI broken.
Of course if the master table is very static it's not a practical
issue. Just a situation where things could turn very sour in the
future if you forget the master table is 'read-only'.
We need commit triggers! (hmm, could you rollback in a after-commit
trigger???)
John
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
Start trans 1 (snapshot or read committed).
Start trans 2 (snapshot or read committed).
Trans 1:
Update master record (so trigger cascased changes to all child
records)
Trans 2:
Insert child record refering to original value in master (which is
still visible in this trans context)
Commit.
Trans 1:
commit.
RI broken.
Of course if the master table is very static it's not a practical
issue. Just a situation where things could turn very sour in the
future if you forget the master table is 'read-only'.
We need commit triggers! (hmm, could you rollback in a after-commit
trigger???)
John
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
> Referential integrity doesn't get broken by deletingthe "children" of the
> referenced key. You place the action rule (ON DELETE CASCADE) onthe
> children to signal that, when the parent key gets deleted, thereferencing
> rows in the "child" table must be deleted also.procedure
>
> It is done by triggers. A trigger is a special kind of stored
> that runs each time the specified operation (DELETE, UPDATE,INSERT)
> happens to a row on the table. It runs only for that row.