Author's note
Because of living money), it has been almost half a year since I switched to work as an electronic product for Apple accessories. After the transfer, my income has indeed increased a lot and my life has indeed benefited a lot, however, I often miss my own programmer career and the days when I was hungry for technology, which made people feel very full; it is precisely because of this nostalgia that only solves one function, algorithm, bug, or even solves one problem for others, so I kept hiding in the blog Park and kept learning. I was busy with stealing and occasionally wrote several small desktop tools to write an application for my IPhone, occasionally, I also discuss some technical issues with my friends who are still engaged in development.
Body
A friend asked me a few days ago if my database's data was deleted by mistake, can it be restored? Because their company maintains a long-running project, the where parameter of delete is written incorrectly during the test, so that some important data is deleted. Because the backup file is too old and the log file is damaged, it cannot be recovered. By the way, find the experts who can solve this problem)
As a result, I cannot help wondering why expired data needs to be deleted?
If you want to delete the information of a departing employee, isn't that the employee's contribution and achievements in the company need to be erased together?
If the company wants to delete a discontinued product, doesn't it mean that all orders containing the product should be deleted together? After cascade, should all customers corresponding to these orders be deleted? The loss of the company is self-evident after such step-by-step deletion.
Employees are not deleted and "fired.
The product is not deleted, but "DISCONTINUED.
The order is canceled because it is not deleted.
The position is not deleted but "filled.
In the above examples, we should focus on the tasks that the user wants to complete, rather than the technical actions that occur on a certain entity. In almost all cases, more than one entity needs to be considered.
To replace the IsDeleted Mark, we can use a field that represents the status of the relevant data: Valid, disabled, canceled, discarded, and so on. You can use this status field to review the past data as a basis for decision-making.
Deleting data not only damages data consistency, but also has other negative consequences. We leave all the data in the database: "Can it be deleted. .".