In SQL databases, transactions are used to maintain atomicity, consistency, isolation, and durability, known as ACID for short. A typical example of a transaction is bank transfers. Debt from a bank account should successfully credit into another account. If the credit fails, the transaction should be rolled back to the initial state and the amount debited should be credited back.
These states are achieved using COMMIT
on success and ROLLBACK
on failure. Even though this works well in a single database system, the process becomes slow in a distributed database environment.
Note
In order to maintain consistency across multiple databases, statements are prepared and executed in all databases and only after getting a success message from all servers is the transaction completed. As the lock is maintained until all the servers commit, the application is slowed down in the process.
For example, in SQL systems, transactions are carried out as follows:
BEGIN TRANSACTION;...