I want to delete a row/tuple from a parent table, but it is throwing an error message because it has a FOREIGN KEY reference in its child table.
However, in my case I want to delete the record only from the parent table and maintain the data in the child table.
Is it possible to achieve this?
I know the usage of ON DELETE CASCADE
, but I want to know if there is a solution for the secenario I described?
deleted
field in your database, and then use views or where clauses to use only rows wheredeleted = 0
. You can also have the foreign key as a composite key of both the id and the deleted field, then useon update cascade
to ensure the child records become soft deleted too. (Also, why is this marked as Four different RDBMS? Are you really using all four?) – Favouritism