Removing Data is not a Best Practice
Removing a line or entity is rarely simple. The operation affects not only the model data but also its form. This is why we use foreign keys, to ensure that the items of an Ordemdecompra are not without an Ordemdecompra associated. And this is the simplest case. ...
When we work with logical removals, it’s easy to get to situations where we have corrupted data since a Client’s Ultimaorder (a simple optimization) may point to an Ordemdecompre that has been logically removed.
Let’s say our marketing department decides to remove a Product from the catalog. Should we then remove all Purchase Orders that contain this Product? Should we also remove all Invoices related to these orders? Going further, we must recalculate the company’s profits?
Let no one let him do it.
In fact, 'removing' a Product means that it will be discontinued. We no longer want to sell that Product line. We want to get rid of the stock we have and never buy from our supplier again. The product should not appear in user surveys, but the warehouse staff still have to manage these items. Anyway it’s much easier to just say 'remove'.
Purchase orders are not removed - they are cancelled. There may even be an incidence of some fee if the order is cancelled too late.
Employees are not removed - they are fired (or retire). Termination can also be handled in the system.
Vacancies are not removed - they are filled.
In all cases we should focus on the task that the user wants to perform instead of the technical action that should be executed in an entity. In almost all situations, more than one entity will be taken into account.
The most correct in all cases is the creation of a field that allows to know in what state the current information is, so it will never be lost any data, allowing in a future to be analyzed for some possible decision making.
Data is of extreme value in any business, especially those related to IT, always keep them stored.
There is no good practice, it depends on what is relevant to your client. If it’s important to keep a track or history of removed items, never delete anything from any table.
– bfavaretto
Got it. Thanks for the explanation.
– Zedu Ricciardi