I tear my hair with the ON DELETE CASCADE Clause. In fact I have two tables I'm on linux and I have installed lamp with phpmyadmin.
That's the tables :
CREATE TABLE a(
Idatable bigint(20) PRIMARY KEY NOT NULL AUTO_INCREMENT,
Nameatable varchar(50) NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE anObject(
IdAnObject bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
Nameobject varchar(20) NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE linkTable(
Idatable bigint(20) NOT NULL REFERENCES a (Idatable),
IdAnObject bigint(20) NOT NULL REFERENCES anObject (IdAnObject) ON DELETE CASCADE,
PRIMARY KEY (Idatable, IdAnObject),
CONSTRAINT linkTable_fk1
FOREIGN KEY (Idatable)
REFERENCES a (Idatable),
CONSTRAINT linkTable_fk2
FOREIGN KEY (IdAnObject)
REFERENCES anObject (IdAnObject) ON DELETE CASCADE
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
Unfortunately, it doesn't work because when I delete a row in the table 'linktable' the associated row in anObject isn't delete
Thank you