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?
世界只因有你2017-06-06 09:52:02
0
5
823
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
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.
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.
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.
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
Discussion of similar issues onhttp://xingaiming.com/2015/12...
sf:
/q/10...
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.
If sensitive data can be flagged, if it is not directly physically deleted
Just delete unimportant data directly. It is better to delete fields like user information. . .