To maintain consistency in the system, I can consider 2 removal strategies:
cascading deletion of all objects in a relationship;
Emulation of deletion (i.e. nothing is deleted from the database, but, for example, the field deletedin essence matters trueand affects the display logic).
I like the second approach, but I don’t know how to implement it correctly.
For example, suppose we are developing a simple blog (users, articles, comments, and other common things). And look at the object User(and the corresponding table User). If we delete a specific user, then his field deletedwill matter true. All user comments will remain where they are, and each reader will still find out who the author of a particular comment is.
All this looks great, but what should I do if a new user (who is trying to register) indicates the same login / email address (other unique fields) that some remote user already has? Theoretically, this unique field value is already free and can be accepted. But what if one day I decide to recover this deleted user?
What are the best practices related to this situation?
Roman source
share