Database Reference
In-Depth Information
We now use an example to study serializability. Each data object has an associated set of
operations, in this case:
 create a new account;
 delete an existing account;
 read-balance takes an account name as argument and returns the balance of the
account;
 check-balance takes an account name and a value as arguments and returns
true if the balance of the account is greater than or equal to the argument value,
else it returns false;
 Credit takes an account name and a value as arguments and adds the argument value to
the balance. Note that the value of the balance is not output to the client;
 Debit takes an account name and a value as arguments and subtracts the argument value
from the balance. Note that the value of the balance is not output to the client.
It is assumed here that the client is responsible for checking the balance before doing a deb-
it. For example, the transfer transaction would contain:
if check-balance (account-A, Rs1000) then debit (account-A, Rs1000) …set-interest-rate
(r%) is used to set the daily interest rate to a given percentage;  add-interest-to-balance is
run daily by the system administration. This operation
computes the interest accrued to the account, based on its value at midnight, and adds the
interest to the balance.
In order for a set of actions to qualify as a transaction, it must pass the ACID test. ACID is
an acronym commonly used when referring to the four characteristics of a transaction:
Atomic: It refers to the all-or-nothing nature of a transaction. Either all operations in a
transaction are performed or none are performed. If some statements are executed and the
transaction fails at any point before it is completed, the results of these executions are rolled
back. Only when all statements are executed properly then the results of that transaction
applied to the database.
Consistent: The database must be consistent at the beginning and at the end of the transac-
tion. A transaction as a set of actions that moves the database from one consistent state to
another. All rules that define and constrain the data must be applied to that data as a result
of any changes that occur during the transaction. All structures of database must be correct
at the end of the transaction.
Search WWH ::




Custom Search