I've got the following situation:
One table containing multiple foreign keys pointing to multiple tables, but only one foreign key to one table. If one record of the primary key is deleted I want to delete the record inside my foreign key table.
Foreign-Key-Table (FK-Column --> FK-Table):
fk_main --> pk_main_table
fk_column1 --> pk_table1
fk_column2 --> pk_table2
fk_column3 --> pk_table3
fk_column4 --> pk_table4
Only one of the fk_columns (fk_columnX) and the fk_main column containing information . The rest is NULL.
The problem is, that I can't create ON DELETE CASCACDE because of loops (but where are they?). Is there a way to get this working?
INFO: pk_table2 is child-member of pk_table1 and has a on delete cascade - but this shouldn't matter? Because if I delete the record in pk_table1 the records in pk_table2 are deleted too, so the cascade could also go to the foreign-key table?
I think I have to use Triggers regarding to this topic?: Foreign key constraint may cause cycles or multiple cascade paths?