title: deleting child before parent MySQL
body: <p>I am developing a database in which there is a primary table with a one to one relationship on another table that references using a foreign key relationship.</p>
  
  <p>Previously, I was using <code>ON DELETE CASCADE</code> for the foreign key table but I have implemented a tracking table which is meant to track anything that is deleted. MySQL doesn't support triggers on delete cascade for foreign keys, so this trigger will not fire for deleting when the cascade occurs. My work around is to delete the child row first from the parent table trigger, which will then cause the foreign key table trigger to fire, thus tracking the deletion of both the child and parent row. I just wanted to ask if this is acceptable practice, or if MySQL might have some other implementation that could be better. On the primary key (parent table) I placed a <code>BEFORE DELETE</code> trigger to make this removal in the foreign key table, and then an <code>AFTER DELETE</code> in the parent table to track the delete of the row for the primary key.</p>
  
  <p>Thoughts?</p>