Problem
In a web application dealing with products and orders, I want to maintain information and relationships between former employees (users) and
That's how I do it. I have a is_deleted field which defaults to 0. Then queries just check WHERE is_deleted = 0.
I try to stay away from any hard-deletes as much as possible. They are necessary sometimes, but I make that an admin-only feature. That way we can hard-delete, but users can't...
Edit: In fact, you could use this to have multiple "layers" of soft-deletion in your app. So each could be a code:
0 -> Not Deleted1 -> Soft Deleted, shows up in lists of deleted items for management users2 -> Soft Deleted, does not show up for any user except admin users3 -> Only shows up for developers.Having the other 2 levels will still allow managers and admins to clean up the deleted lists if they get too long. And since the front-end code just checks for is_deleted = 0, it's transparent to the frontend...