Wednesday, October 26, 2011

ACID Property


Question  :: Explain ACID Property and Importance of each ?
Answer:
ACID Means:
A -Atomicity
C - Consistency
I - Isolation
D - Durability


Atomicity: 
Either all operations of the transaction are reflected properly in the
Database, or none are.
Let Ti be a transaction that transfers $50 from account A to account B. This
transaction can be defined as
Ti: read(A);
A := A − 50;
write(A);
read(B);
B := B + 50;
write(B)
Suppose that, just before the execution of transaction Ti the values of
accounts A and B are $1000 and $2000, respectively. Now suppose that, during the
execution of transaction Ti, a failure occurs that prevents Ti from completing its
execution successfully. Examples of such failures include power failures, hardware
failures, and software errors. Further, suppose that the failure happened after the
write(A) operation but before the write(B) operation. In this case, the values of
accounts A and B reflected in the database are $950 and $2000. The system
destroyed $50 as a result of this failure. In particular, we note that the sum A + B
is no longer preserved.
The basic idea behind ensuring atomicity is this: The database system keeps
track (on disk) of the old values of any data on which a transaction performs a
write, and, if the transaction does not complete its execution, the database system
restores the old values to make it appear as though the transaction never executed.



Consistency: 
If single transaction or more than two transactions executing concurrently then it should preserve the consistency of the database, i.e. Transaction must be in consistent states. The consistency requirement here is that the sum of A and B be unchanged by the execution of the transaction. Without the consistency requirement, money could be created or destroyed by the transaction! It can be verified easily that, if the database is consistent before an execution of the transaction, the database remains consistent after the execution of the transaction.


Isolation:
Even if the consistency and atomicity properties are ensured for each
transaction, if several transactions are executed concurrently, their operations may
interleave in some undesirable way, resulting in an inconsistent state. Even though
multiple transactions may execute concurrently, the system guarantees that, for
every pair of transactions Ti and Tj , it appears to Ti that either Tj finished
execution before Ti started, or Tj started execution after Ti finished. Thus, each
transaction is unaware of other transactions executing concurrently in the system.


Durability: 
After a transaction completes successfully, the changes it has made to the database persist, even if there are system failures.Once the execution of the transaction completes successfully, and the user who initiated the transaction has been notified that the transfer of funds has taken place, it must be the case that no system failure will result in a loss of data corresponding to this transfer of funds.The durability property guarantees that, once a transaction completes successfully, all the updates that it carried out on the database persist, even if there is a system failure after the transaction completes execution.




No comments:

Post a Comment