Page 1 of 1

DB2 delete cascading not working

PostPosted: Sat Dec 05, 2009 3:39 am
by alwin007
Hi I am creating four tables :

event (ecode, edesc, elocation, edate, etime, emax)
spectator (sno, sname, semail)
ticket (tno, ecode, sno)
cancel (tno, ecode, sno, cdate, cuser)

I have set ecode as PRIMARY KEY for event and tno for Ticket and sno for Spectator.
I added delete cascade in ticket for ecode and sno but it works fine with sno, that is when i delete a spectator the attribute is deleted from the child table too but the same is not happening with event:

CREATE TABLE ticket (
tno INT NOT NULL,
ecode CHAR(4) NOT NULL,
sno INTEGER NOT NULL,
CONSTRAINT ticket_pk PRIMARY KEY (tno),
FOREIGN KEY (ecode) REFERENCES event
ON DELETE CASCADE,
FOREIGN KEY (sno) REFERENCES spectator
ON DELETE CASCADE
);

What am i doing wrong?Please help