Working on a project at the moment and we have to implement soft deletion for the majority of users (user roles). We decided to add an is_deleted='0'
field on each table in the database and set it to '1'
if particular user roles hit a delete button on a specific record.
For future maintenance now, each SELECT
query will need to ensure they do not include records where is_deleted='1'
.
Is there a better solution for implementing soft deletion?
Update: I should also note that we have an Audit database that tracks changes (field, old value, new value, time, user, ip) to all tables/fields within the Application database.
You could perform all of your queries against a view that contains the WHERE IS_DELETED='0'
clause.