Foreign keys, Triggers, and Audits, Oh My!

I’m going to answer my own post, as I hope that it will help another user with the same question. After thinking about this for a few days, I realized that the way to have both triggers and foreign keys is to use a restricted as opposed to a cascading delete.

Basically, using PHP, I’ll code each of the deletes of the children table, in which case I can also apply a trigger to save the information to my audit table. Though I don’t have the advantage of the minimally coded cascading delete, I still have the very important advantage of referential integrity as afforded by the use of foreign keys.

And, in retrospect, I’m sure that this was a super noob question for most, but hopefully there’s at least one other noob out there who will find my self-posted solution to be helpful.

1 Like