My question that maybe - hopefully not - can be considered as opinion, is conceptual and even simple.
In most applications, we work with features that when used by multiple users at the same time, can cause some problem in the database. In my application, I have events that trigger information for two, three, and even more tables, and if there are too many users editing this information at the same time, some inconsistency may occur.
In general at these times, I create fields to store the id
of the user that is entering the module and with that, it is worth not having a id
stored to release - or not - the edition. If there is a user editing and a new one tries to access the module, I display a message and give the user the option to continue editing or wait for the end.
If the user chooses to proceed, I change the id
stored by that user and invalidate the changes of the first user, because before sending the changes, I check if it has id
corresponding to the stored in table.
How can there be a session crash, a power outage, and other natural phenomena - or not - that prevent the user from finishing, cleaning the field that stores id
daily.
Is there a model that applies more security and / or practicality and / or organization for tasks of this type? Is there any way to work with this without needing to create fields that store the id
of the current user?