Should I delete or disable a row in a relational database?

后端 未结 18 2360
忘了有多久
忘了有多久 2020-12-23 10:09

In a brand new program where space isn\'t really that big a deal, is it better to delete a row or to disable a row by let\'s say a boolean \"Disabled\" and have the program

18条回答
  •  误落风尘
    2020-12-23 10:51

    I am creating a CRUD and i'm facing the same problem.

    Solution : The D of CRUD should disable instead of delete.

    Problems:

    • "Every" query should check if the registry is disable or not (flag=1 for example). More specifically, ever select * should check that.
    • Every insert should activate the registry (flag=1) by default.
    • Update shouldn't change the flag.
    • Disable is an update in disguise that marks the flag=0.

    Big Problem

    • Garbage collector. Exists three strategies : to delete old registries, to delete registries that are not referenced or a mix of strategies.

提交回复
热议问题