search

Home  >  Q&A  >  body text

mysql - If a piece of data is no longer useful in the data table, is it better to delete it or set a field to indicate that it has been deleted?

I often encounter this problem. I remember I heard someone say that setting a field indicates that it has been deleted. I usually use this method. I want to know which one is better? thank you all

世界只因有你世界只因有你2733 days ago797

reply all(5)I'll reply

  • 漂亮男人

    漂亮男人2017-06-06 09:54:02

    Today’s data is generally logically deleted, which is what you mentioned, and the other is physical deletion in the database. Just delete the data directly. Logical deletion is suitable for data that has been deleted by the user, but the website still needs statistics, while physical deletion can be used for data that is meaningless after verification, such as mobile phone verification codes.

    reply
    0
  • 为情所困

    为情所困2017-06-06 09:54:02

    It is recommended to mark it. For specific reasons, you can refer to the articles I excerpted before.

    Database design principles – don’t delete data
    http://xingaiming.com/2015/12...

    Discussion of similar issues on

    sf:
    /q/10...

    reply
    0
  • 黄舟

    黄舟2017-06-06 09:54:02

    No deletion: In many cases, it just takes up more disk space. Does not affect system performance

    Delete: It doesn’t matter. In most cases, the scenarios you expect to use these deleted data will not actually occur. If it appears, then this function should be marked, not soft deleted.

    So, when you encounter this kind of problem in the future and are at a loss, just choose the first one. Since there isn't much difference between the options, there isn't much to choose from.

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-06-06 09:54:02

    If sensitive data can be flagged, if it is not directly physically deleted

    reply
    0
  • 漂亮男人

    漂亮男人2017-06-06 09:54:02

    Just delete unimportant data directly. It is better to delete fields like user information. . .

    reply
    0
  • Cancelreply