Implementation of Atomicity

Posted by Programming Help
4
May 30, 2016
108 Views

Atomicity is part of ACID property of transaction

• Atomic

Process all of a transaction or none of it; transaction cannot be further subdivided (like an atom)

• Consistent

Data on all systems reflects the same state

• Isolated

Transactions do not interact/interfere with one another; transactions act as if they are independent

• Durable

Effects of a completed transaction are persistent

We will consider the banking example to gain a better understanding of the acid properties and why are they important. We will consider a banking system that contains several accounts and a set of transactions that accesses and updates accounts. Access to a database is accomplished by two operations given below:- 

1. Read(x)-This operation transfers the data item x from the database to a local buffer belonging to the transaction that executed the read operation

2. Write(x)-the write operation transfers the data item x from the local buffer of the transaction that executed the write operation to the database. 

Now suppose that Ti is a transaction that transfers 2000 from account CA2090 to SB2359. This transaction is defined as follows:-

Ti:

Read(CA2090);

CA2090:=CA2090-2000;

Write (CA2090);

Read (SB2359);

SB2359:=SB2359+2000;

Write (SB2359);

Implementing Atomicity on above

Let's assume that before the transaction take place the balances in the account is 50000 and that in the account SB2359 is 35000. Now suppose that during the execution of the transaction a failure (for example, a power failure) occurred that prevented the successful completion of the transaction. The failure occurred after the Write(CA2090); operation was executed, but before the execution of Write(SB2359); in this case the value of the accounts CA2090 and SB2359 are reflected in the database are 48,000 and 35000 respectively. The 200 that we have taken from the account is lost. Thus the failure has created a problem. The state of the database no longer reflects a real state of the world that the database is supposed to capture. Such a state is called an inconsistent state. Learn how to Develop a Database Management System Assignment

The database system should ensure that such inconsistencies are not visible in a database system. It should be noted that even during the successful execution of a transaction there exists points at which the system is in an inconsistent state. But the difference in the case of a successful transaction is that the period for which the database is in an inconsistent state is very short and once the transaction is over the system will be brought back to a consistent state. So if a transaction never started or is completed successfully, the inconsistent states would not be visible except during the execution of the transaction. 

This is the reason for the atomicity requirement. If the atomicity property provided all actions of the transaction are reflected in the database of none are. The mechanism of maintaining atomicity is as follows The DBMS keeps tracks of the old values of any data on which a transaction performs a Write and if the transaction does not complete its execution, old values are restored to make it appear as though the transaction never took place. The transaction management component of the DBMS ensures the atomicity of each transaction.

Atomicity

Atomicity is part of ACID property of transaction

• Atomic

Process all of a transaction or none of it; transaction cannot be further subdivided (like an atom)

• Consistent

Data on all systems reflects the same state

• Isolated

Transactions do not interact/interfere with one another; transactions act as if they are independent

• Durable

Effects of a completed transaction are persistent

We will consider the banking example to gain a better understanding of the acid properties and why are they important. We will consider a banking system that contains several accounts and a set of transactions that accesses and updates accounts. Access to a database is accomplished by two operations given below:- 

1. Read(x)-This operation transfers the data item x from the database to a local buffer belonging to the transaction that executed the read operation

2. Write(x)-the write operation transfers the data item x from the local buffer of the transaction that executed the write operation to the database. 

Now suppose that Ti is a transaction that transfers 2000 from account CA2090 to SB2359. This transaction is defined as follows:-

Ti:

Read(CA2090);

CA2090:=CA2090-2000;

Write (CA2090);

Read (SB2359);

SB2359:=SB2359+2000;

Write (SB2359);

Implementing Atomicity on above 

Let's assume that before the transaction take place the balances in the account is 50000 and that in the account SB2359 is 35000. Now suppose that during the execution of the transaction a failure (for example, a power failure) occurred that prevented the successful completion of the transaction. The failure occurred after the Write(CA2090); operation was executed, but before the execution of Write(SB2359); in this case the value of the accounts CA2090 and SB2359 are reflected in the database are 48,000 and 35000 respectively. The 200 that we have taken from the account is lost. Thus the failure has created a problem. The state of the database no longer reflects a real state of the world that the database is supposed to capture. Such a state is called an inconsistent state. 

The database system should ensure that such inconsistencies are not visible in a database system. It should be noted that even during the successful execution of a transaction there exists points at which the system is in an inconsistent state. But the difference in the case of a successful transaction is that the period for which the database is in an inconsistent state is very short and once the transaction is over the system will be brought back to a consistent state. So if a transaction never started or is completed successfully, the inconsistent states would not be visible except during the execution of the transaction.

This is the reason for the atomicity requirement. If the atomicity property provided all actions of the transaction are reflected in the database of none are. The mechanism of maintaining atomicity is as follows The DBMS keeps tracks of the old values of any data on which a transaction performs a Write and if the transaction does not complete its execution, old values are restored to make it appear as though the transaction never took place. The transaction management component of the DBMS ensures the atomicity of each transaction.

Comments
avatar
Please sign in to add comment.