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
761

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

世界只因有你
世界只因有你

reply all(5)
漂亮男人

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
http://xingaiming.com/2015/12...

Discussion of similar issues on

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.

过去多啦不再A梦

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. . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!