What is transaction processing? Explain the properties of the transaction(DBMS)

DBMSDatabaseBig Data Analytics

A transaction is a unit of database processing which contains a set of operations. For example, deposit of money, balance enquiry, reservation of tickets etc.

Every transaction starts with delimiters begin transaction and terminates with end transaction delimiters. The set of operations within these two delimiters constitute one transaction.

main()
{ begin transaction
} end transaction

Operations

The transaction has two basic operations −

  • Read(x) − Load the data-item x from database to memory. {Database is present in hard-disk}.

  • Write(x) − Update the data-item x in memory and store it in the database.

Properties of transaction

Database system ensures ACID property, which is explained below −

  • Atomicity − Either all or none of the transaction operation is done.

  • Consistency − A transaction transfer from one consistent (correct) state to another consistent state.

  • Isolation − A transaction is isolated from other transactions. i.e. A transaction is not affected by another transaction. Although multiple transactions execute concurrently it must appear as if the transaction are running serially (one after the other).

  • Durability − The results of a transaction are permanent i.e. the result will never be lost with subsequent failure, durability refers to long lasting i.e. permanency.

Example

Consider the transaction to transfer Rs. 150 from Account A to Account B. The steps for the transaction are as follows −

  • Read A
  • A=A-150
  • Write(A)
  • Read(B)
  • B=B+150
  • Write(B)

Atomicity is required if the transaction fails at step 4 and then there is inconsistency due to partial modification. This is because the value of B is not updated.

Consistency requirement − The sum of A and B should be the same before and after transaction.

Isolation requirement − If another transaction accesses data during step 4 then there is inconsistency because the value of B is not updated till now.

raja
Published on 06-Jul-2021 13:57:39
Advertisements