SQL Rational Links Between Tables [message #40150] |
Wed, 11 September 2002 10:43 |
Don Wray
Messages: 2 Registered: September 2002
|
Junior Member |
|
|
I'm trying to take 3 tables in a database and make a rational link between them that will explain to each that if a record is deleted in 1 then it should be deleted in the other 2 as well... this is for a card access and biometric system and i'm just lost on how to do this integration... plz help...
Signed,
LAMER
|
|
|
Re: SQL Rational Links Between Tables [message #40151 is a reply to message #40150] |
Wed, 11 September 2002 10:51 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
Since the delete can go "any way", not just from parent to child, you won't be able to use declarative referential integrity to handle the delete - instead, you can use a trigger on each table. Here is what the trigger on table a (of a, b, c) would look like:
create or replace trigger a_trg
after delete on a
for each row
begin
delete
from b
where id = :old.id;
delete
from c
where id = :old.id;
end;
09-11-01
|
|
|
|