DBMS Transaction Management: Introduction (ACID properties )

 DBMS Transaction Management: Introduction (ACID properties )

Introduction

  • ·         A database transaction: -
  • ·         A set of logically related operation Involve in one or more database access operation.
  • ·         Contains a group of tasks.
  • ·         Represent real-world events of any enterprise.
  • ·         All database operation held between the beginning and end transaction statements.
  • ·         Considered a single logical transaction.
  • ·         During the transaction, the database is in inconsistent state.
  • ·         When it is committed the state is changed from one consistent state to another.
  • ·         If the database operations do not update the database but only retrieve data, this type of transaction is called a read-only transaction.


Example: Suppose an employee of bank transfers Rs 800 from X's account to Y's account. 

X's Account

1. Open_Account(X)

2. Old_Balance = X.balance

3. New_Balance = Old_Balance - 800

4. X.balance = New_Balance

5. Close_Account(X)

Y's Account

1. Open_Account(Y)

2. Old_Balance = Y.balance

3. New_Balance = Old_Balance + 800

4. Y.balance = New_Balance

5. Close_Account(Y)

 

Transaction property

  • For maintaining the integrity of data, the DBMS transaction the property known as ACID properties.
  • The transaction has four properties.
  • Used to maintain consistency in a database, before and after the transaction.

 

Property of Transaction

1. Atomicity

2. Consistency

3. Isolation

4. Durability


 
1.  Atomicity

  • ·         A transaction is a single unit of operation. You either execute it entirely or do not execute it at all.
  • ·         Not be partial execution.
  • ·         All operations of the transaction take place at once if not, the transaction is aborted.
  • ·         No midway, i.e., the transaction cannot occur partially.
  • ·         Treated as one unit and either run to completion or is not executed at all.

 

Atomicity involves the following two operations:

  • ·         Abort (failed): all the changes made are not visible.
  • ·         Commit (change successfully): all the changes made are visible.

 

Example: Let's assume that the following transaction T consisting of T1 and T2. Consists of Rs 600 and B consists of Rs 300. Transfer Rs 100 from account A to account B.


 

 

1.    Consistency

  • ·         The integrity constraints are maintained so that the database is consistent before and after the transaction.
  • ·         The transaction is used to transform the database from one consistent state to another consistent state.

 

For example, The total amount must be maintained before or after the transaction.

1. Total before T occurs = 600+300=900

2. Total after T occurs= 500+400=900

Therefore, the database is consistent. In the case when T1 is completed but T2 fails, then

inconsistency will occur.

 

2.  Isolation

  • It shows that the data which is used at the time of execution of a transaction cannot be used by the second transaction until the first one is completed.
  • In isolation, if the transaction T1 is being executed and using the data item X, then that data item can't be accessed by any other transaction T2 until the transaction T1 ends.
  • The concurrency control subsystem of the DBMS enforced the isolation property.

 

3.  Durability

  • Indicates the performance of the database's consistent state.
  • The transaction made permanent changes.
  • Not lost by the wrong operation of a faulty transaction or by the system failure.
  • Recovery subsystem responsible for Durability property.

 

==========================================================   



Post a Comment

0 Comments