java - Deleting entities strategy -
To keep the system stable, I can consider the removal strategy:
-
To destroy all institutions in relationships; Removing duplicate (i.e. anything is actually not removed from DB, but for example, the field in the unit
deleted
value -
Code> true and it affects the argument that displays).
I like the second approach but I do not know how to implement it properly
For example, suppose we have a simple blog (Users, articles, comments and other common stuff). And see that the user
unit (and a correspondent table user
) is available. If we delete some users then they will have value in the deleted
area true
will be all user comments where every reader will still know who is the author of a particular comment .
All this looks good but what should I do if a new user (who is trying to register) will specify the same login / email address (other unique fields) as if something was deleted Already a user? In theory, this unique field value is already free and can be taken. But, what would happen if one day I decide to delete that deleted user?
What are the best practices related to this situation?
It really depends on your specific requirements and the requirements of the system you are working on.
Usually a "soft-delete" function is desired in cases like the first part of your example where users are "deleted", so you do not want to delete your content from the system. However, in this situation you have a fall that the user account is always in use, and you will not be able to reuse that account for anyone else in the future.
In other situations the "cascading delete" option has been preferred, but can be a very interesting animal to manage it, because with multiple cascading obstacles, even a single deletion can be removed from multiple tables Can affect
I think it is important to understand that you really want to fulfill both solutions, they are actually valid. This is only a specific business case that is most suitable for a particular implementation.
Comments
Post a Comment