Search code examples
sqlrollbackdatabase-backupsdata-entrydata-management

Handle rollbacks for data edits in a multi-user environment?


How to you typically handle roll backs for data edits in a multi-user environment? Do you identify the transaction and build a graph of any subsequent dependent transactions and then roll them all back ? Do most RDBMS's provide an interface or mechanism to do this sort of thing?

Naive as I am, I thought about restoring from backup, but then I realize that this would revert the changes made to unrelated records by potentially tens of users. between the time of the edit/backup and the present time.


Solution

  • (Based on SQL Server)

    Normally, if your edits are placed withing in a BEGIN TRANSACTION ... COMMIT TRANSACTION, this will lock the relavant tables/fields etc so that other users cannot edit the same data.

    You can also ROLLBACK the transaction as well as nest transactions which can be rolledbacked.

    A lot will depend how the users access the data from the database.