Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL Foreign Key "ON DELETE CASCADE" across 3 tables
    text
    copied!<p>I have 3 tables in my DB (there are more, but there are no connections to these yet)</p> <ul> <li>table "molecule" with column id</li> <li>table "descriptor" with columns "id" and "molecule_id" and a foreign key referencing "molecule.id"</li> <li>table "tDepDescriptor" with columns "id" and "descriptor_id" and a foreign key referencing "descriptor.id "</li> </ul> <p>(each table has more columns, but none of these act as foreign keys or anything like that)</p> <p>All foreign keys have "on delete cascade" specified, all ids are unsigned int(5). </p> <p>Now, if I try to delete an entry in "molecule" for which there are referencing entries in "descriptor" and "tDepDescriptor" nothing happens as if the foreign keys were set to "on update restrict", no error is given. If I delete an entry in "descriptor", all referencing entries in "tDepDescriptor" are deleted like they should. The same happens if I try to delete an entry in "molecule" for which there are referencing entries in "descriptor", but no referencing entries to those "descriptor"-entries in "tDepDescriptor". So "on delete cascade" works for two tables, but the "cascade" does not seem to be passed on when three tables are involved. </p> <p>What the tables are supposed to do is: When I want to delete an entry in "molecule", all referencing entries in "descriptor" are deleted. And therefore all entries in "tDepDescriptor" that have a reference to one of the deleted entries in "descriptor" are also deleted. </p> <p>mysql server version is 5.1, engine is InnoDB</p> <p>Is hope someone could follow this complicated explanation and can help me. </p> <p>//EDIT: Found the problem. Seems to be a problem with phpMyAdmin, not with the database. clicking on delete in PMA did not work, but coding the query by hand did, cascading through all three tables. Strange, but at least I know my tables work correctly. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload