Most of my databases have something to do with logging who is doing what among other things. As such, I have a table for employees with all their information and link that information to the audit record using the primary key. My issue then is what is the best way to "delete" a user when they no longer work for the company? If I actually delete the employee record, then I end up with orphaned records in the audit table.
I'm not looking for exact code or some special procedure. I'm just needing an idea for how everyone else handles this. I've used a couple of methods personally, and none get me real excited.
Things I've tried:
1) Create a "Deleted User" employee and when I want to delete a user, all their audit records get assigned to the "Deleted User" before actually deleting the employee.
2) Have an "Active" flag on the employee record so that when they quit, the flag gets unchecked and thereby removed from all available employee lists.
3) I haven't done this one, but thought about it. Instead of using the employee's primary key to create a link in the audit table, I could use the employee's name. Then when the employee's record is deleted, the name is still sitting in the audit table and the orphaned record doesn't matter.
4) Do nothing and let the list of employees keep growing.
Again, I'm not looking for specific code. Just wanting some general ideas for how to handle it.