Intro to DBMS

Transaction in Database

  • It is a set of operations used to perform a logical unit of work. For example, work is to withdraw money. To withdraw money, it needs to transaction some amount from one account to another account through ATM or online, etc.
  • A transaction generally represents a change in the database.

How is the Transaction actually performed?

As we know, All banks contain their database Server, which holds all information of their account holders. When it needs to transaction, then the following basic operations are performed on data.

  • READ: Information of the sender account is fetched from the Hard DISK of the DATABASE SERVER to the MAIN Memory of the Sending Device.
  • WRITE: Now fetched information can change according to the transaction need through CPU. Still, all the changes are in the Main memory.
  • In the last step, the commit command made the permanent changes in the database of the hard disk server.

Note: Command Rollback: It is used to undo the work done.


Let’s take an example of a simple transaction. Suppose a bank employee transfers Rs. 1000 from A’s account to B’s account. This simple transaction contains several low-level mini-tasks.

A’s Account

  • Open_Account(A)
  • Old_Balance = A.balance                      // READ (fetch information)
  • New_Balance = Old_Balance – 1000   // ALU operation on data
  • A.balance = New_Balance                    // WRITE (update in main memory)
  • Close_Account(A)                                 // commit (to perform permanent changes in the database)

B’s Account

  • Open_Account(B)
  • Old_Balance = B.balance
  • New_Balance = Old_Balance + 1000
  • B.balance = New_Balance
  • Close_Account(B)