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

后端 未结 18 2261
忘了有多久
忘了有多久 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:55

    If you will need the deleted data sometimes, but not very often: you can move the records into a separate database/table (e.g. users and users_deleted, or better somedb.users and somedb_deleted.users).

    This way, the data is still accessible through a query (although it won't be as simple as the normal one), yet it doesn't clutter the original database and you don't have to code around it.

提交回复
热议问题