Transaction Processing Concept in ADO.NET

Transaction:

  • Transaction is a unit of program execution that access and possibly updates various data items.

  • A Transaction must see a consistence data base.

  • During transaction execution the database may be temporarily inconsistent.

  • when the transaction complete successfully (is committed ), the database must be consistent.

  • After transaction commits, the change it has made to the database persist. even if there are system failures.

  • Multiple transaction can execute in parallel.

  • Transaction boundaries: begin/end.

  • There are many types of transaction e.g. read only transaction, read-write transaction.   

Example:

Move $45 from checking to saving a/c

  • To user, transaction appear as one activity as follows.

  • To database, it is a series of activity as follows:
        Read balance to checking a/c: Read(X).
        Read balance if saving a/c: Read(Y).
        Subtract $45 to Y.
        Write new value of X back to disk.
        write new value of Y back to disk.

Basic access operations of transaction:

A transaction can have two basic functions (operation):

  • read_item(x): Read a database item named x into a program variable.

  • write_item(x): Write the value of program variable x in to database item named x.

  • Read_Set(x): All items that transaction reads.

  • Write_Set(x): All items that transaction writes. 

Transaction State:

There are five state of a transaction, that are

  • Active:- The initial state , the transaction stays in this state while it is executing.

  • Partially Committed:- After the final statement has been executed. 

  • Failed:- After discovery that normal execution can no longer proceed.

  • Aborted:- After the transaction has been rolled back and the database restore to its state prior to the start of the transaction. Two options after it has been aborted:
       Restart the transaction: can be done only no internal logical error.
       Kill the transaction.

  •  Committed:- after successfully completion.   

 Transaction-state.gif