What is a transaction?
The Transaction is a unit of data processing. For instance, many of the transactions at a bank may be withdrawal or deposit of money; transfer of money from A's account to B's account etc. A transaction would include manipulation of one or more data values in a database. Therefore, it may need reading and writing of database value. For instance, the withdrawal transactions can be written in pseudo code as:
Example:
; Suppose that we are doing this transaction for person
; whose account number is X.
TRANSACTION WITHDRAWAL (withdrawal_amount)
start transaction
IF X exist then
READ X.balance
IF X.balance > withdrawal_amount THEN
SUBTRACT withdrawal_amount
WRITE X.balance
COMMIT
ELSE
DISPLAY "TRANSACTION CANNOT BE PROCESSED"
ELSE DISPLAY "ACCOUNT X DOES NOT EXIST"
End transaction;
Another same example may be transmitting of money from Account no x to account number y. This transaction may be written as: