什么是实现软删除的最好的方法? [英] What is the best way to implement soft deletion?
问题描述
目前正在处理一个项目,我们必须为大多数用户(用户角色)实现软删除。我们决定在数据库中的每个表上添加一个is_deleted ='0'字段,如果特定用户角色在特定记录上命中一个删除按钮,则将其设置为1。
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.
为了以后的维护,每个SELECT查询将需要确保它们不包括is_deleted ='1'的记录。
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.
推荐答案
您可以对包含 WHERE IS_DELETED ='0'
子句。
这篇关于什么是实现软删除的最好的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!