The magic
word is "transactions".
Transactions are what you use to ensure the integrity of a shared database when multiple users can be updating at the same time.
Briefly, you start a transaction. Then you do your database operations. Then you commit your transaction. Until you commit the transaction, none of your changes actually take effect in the database.
If you encounter problems while doing the update, you can rollback the transaction. That cancels the transaction and discards the changes that would have been committed.
A variation on transactions is "locking". A lock is where you mark a table, record, or whatever as being held by 1 user and no one else can mess with that database resource until the lock has been released. Locks used to be the way to do things back when mainframes ran databases and databases were more primitive. These days, transactions generally rule.