foreign key constraint fails



Hallo,

folgende Tabellenstruktur (InnoDB)

Tabelle kunden
kdnr | name
12 | Paul
18 | Max


Tabelle produkte
prod_id | artikelname
17 | tasse
20 | maus
11 | haus
15 | katze


Tabelle favoritenlisten:
fali_id | kdnr | fali_name
1 | 12 | hurz
2 | 12 | purz
3 | 18 | foo
FOREIGN KEY (`kdnr`) REFERENCES `kunden` (`kdnr`) ON UPDATE CASCADE,
FOREIGN KEY (`kdnr`) REFERENCES `kunden` (`kdnr`) ON DELETE CASCADE


Tabelle favoritenlisten_produkte:
fali_id | prod_id
1 | 17
1 | 20
1 | 11
2 | 15
FOREIGN KEY (`fali_id`) REFERENCES `favoritenlisten` (`fali_id`) ON UPDATE CASCADE,
FOREIGN KEY (`fali_id`) REFERENCES `favoritenlisten` (`fali_id`) ON DELETE CASCADE
FOREIGN KEY (`prod_id`) REFERENCES `produkte` (`prod_id`) ON UPDATE CASCADE,
FOREIGN KEY (`prod_id`) REFERENCES `produkte` (`prod_id`) ON DELETE CASCADE

Folgendes Statement
DELETE FROM favoritenlisten WHERE kdnr = 12 AND fali_id = 1
sollte nun den Datensatz in favoritenlisten löschen und die 3 dazugehörigen Datensätze in favoritenliste_produkte. Ich ernte mit MySQL 4.0.25 aber immer nur ein "1217 - Cannot delete or update a parent row: a foreign key constraint fails".

Im Manual heißt es zu dem Fehlercode "You are trying to delete a parent row that has children, and a foreign key constraint fails. You should delete the children first." Es ist ja nicht der Sinn von Foreign Keys, dann doch wieder applikationsseitig für konsistente Daten sorgen zu müssen. Wo könnte die Ursache liegen?

Danke

Guido



.



Relevant Pages

  • Re: Multiple Cascade Paths
    ... you even try to look at the base table in a trigger, or no triggers at ... > I have an issue with foreign key constraints and multiple cascade paths as ... > fkinatob int not null foreign key references aon update cascade ...
    (microsoft.public.sqlserver.programming)
  • Re: Unique PK across two tables?
    ... > identifier (VIN), and add two mutually exclusive sub-classes, Sport ... > FOREIGN KEY ... > REFERENCES Vehicles ... > ON DELETE CASCADE, ...
    (microsoft.public.sqlserver.programming)
  • Re: CASCADE !!
    ... Defining a cascading Foreign Key will do this for you. ... (category_group_id INT IDENTITY(1,1) ... REFERENCES category_group ... > ON DELETE CASCADE) ...
    (microsoft.public.sqlserver.server)
  • sql server 2000 Delete performance
    ... Computer: Dual processor Zeon 2.4GHZ(each ... CONSTRAINT FOREIGN KEY ... REFERENCES ( ... ON DELETE CASCADE ON UPDATE CASCADE, ...
    (microsoft.public.sqlserver.programming)
  • Re: Foreign Key Problem errno 150
    ... CONSTRAINT `FK_tblstammblatt_aufsteck` FOREIGN KEY REFERENCES ... So interpretiere ich die Anleitung. ...
    (de.comp.datenbanken.mysql)

Loading