First of all, we should note that from the moment the user reads the data, receives them on the page, changes them, and then tries to write them back. Thus, we are not talking about the lock command in SQL, but about any other lock that occurs in milliseconds and helps to synchronize threads, but here we need to synchronize people and what they write.
There is also a problem if the user for some reason leaves the page, and this can block the data forever.
This problem can be solved using two approaches.
simple , when the user tries to save the data, you have to check if the same data has been changed in the middle, and warn him or show the merge dialog or merge programticall or something similar - I do not know what you won.
the difficult way is to constantly monitor the page that reads and changes data, and save the results of this monitor in a common table in the database, and there, if the user has been and remains the page, other users receive warnings and read-only data until the user leaves.
This monitor should be made using javasript and should know even if the user gives up the page.
source share