|
|
|
Examples of transactions:
|
|
|
|
|
|
|
I will use a integer value as data item in the example below to explain the operations
|
|
|
|
Important fact:
|
|
|
|
begin_transaction
read_item(X)
X.balance = X.balance - N
write_item(X)
read_item(Y)
Y.balance = Y.balance - N
write_item(Y)
end_transaction
|
begin_transaction
read_item(X)
X.balance = X.balance + N
write_item(X)
end_transaction
|
|
|
Either of these situations will cause inconsistency in the database system
|
Initial database state:
X.balance = 1000
Y.balance = 2000
|
Result:
|
|
|
Initial database state:
X.balance = 1000
Y does not exist (erroneous account)
|
Result:
|
|