51. What is a transaction.

To emulate a business transaction, a program may need to perform several steps. A financial program, for example, might transfer funds from a checking account to a savings account with the steps listed in the following pseudocode:

begin transaction 
   debit checking account 
   credit savings account
   update history log 
commit transaction

Either all three of these steps must complete, or none of them at all.

Otherwise, data integrity is lost. Because the steps within a transaction are a unified whole, a transaction is often defined as an indivisible unit of work.

  • A transaction can end in two ways: with a commit or a rollback.
  • When a transaction commits, the data modifications made by its statements are saved.
  • If a statement within a transaction fails, the transaction rolls back, undoing the effects of all statements in the transaction.
  • In the pseudocode, for example, if a disk drive crashed during the credit step, the transaction would roll back and undo the data modifications made by the debit statement. Although the transaction failed, data integrity would be intact because the accounts still balance.
  • In the preceding pseudocode, the begin and commit statements mark the boundaries of the transaction.

Transaction mainly consist of ACID. A-Atomicity, C- Consistency, I – Integrity, D- Durability. If a process consist of acid successfully then we can say that the transaction is successful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: