I want to delete 2 rows of 2 tables that have mutual constraints. I can't modify the database structure.
The structure is something like this:
A (id, b_id, other_data) FOREIGN KEY (b_id) REFERENCES B(id)
B (id, a_id, other_data) FOREIGN KEY (a_id) REFERENCES A(id)
I thought that if I delete the 2 rows in the same transaction the constraints will be checked at the end, but I am having an error of constraint violation when tries to delete the first one.
Which is the right way to do this?