What to do when I want to use database constraints but only mark as deleted instead of deleting?

后端 未结 10 1004
野的像风
野的像风 2020-12-31 20:55

I am working in a project where database items are not deleted, but only marked as deleted. Something like this:

id   name     deleted
---  -------  --------         


        
10条回答
  •  借酒劲吻你
    2020-12-31 21:41

    It might be worth considering using a "recycle bin" table. Instead of keeping the old records in the same table with a flag, move them to its own table with its own constraints. For instance, in the active table you do have a UNIQUE constraint on name, but in the recycle bin table you don't.

提交回复
热议问题