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

后端 未结 10 1088
野的像风
野的像风 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:28

    For example, you can add an illegal character (*) to the deleted name. But you still have problems undeleting a deleted item. So probably the better idea is to prohibit double names even if they are deleted.

    You can clean the deleted records after an amount of time (or move them to a separate table).

提交回复
热议问题