Tuesday 12 June 2012

Database Transaction

A Database Transaction can be understood as single unit of a logical operation in a database. It consists of one or more data operations performed together.

To understand the concept, let's take an example of a database of a bank. Here we have two accounts one for Mr. A and other for Mr. B represented by Table A and Table B in the database.

To transfer some amount of money from Mr. A's account to Mr. B's account as a payment, there are two logical steps:
  1. Deduct money from Mr A's account. i.e. Make an entry of money withdrawal in Table A.
  2. Deposit same amount of money to Mr. B's account. i.e. Make an entry of money depositin Table B.
There is no sense in doing either one of these steps alone. So, any of these steps alone doesn't qualify as a transaction.
It makes sense only when both of these steps are performed together. Hence constitute as a logical operation.  i.e. Transaction.

Here is a more detailed article on the topic on Wikipedia. You might be interested in this article as well.

No comments:

Post a Comment