Database transaction, Examples, Difference between Commit and Rollback, transaction properties

Database transaction, Examples, Difference between Commit and Rollback, transaction properties

In this tutorial, we will learn about the followings;

  1. Database transaction
  2. Examples of Database transaction
  3. Difference between Commit and Rollback
  4. Transaction properties

What is Database transaction?

The transaction is a collection of one or more operations that must be completed together to perform a successful operation. A transaction can be a successful transaction if it all operations are successfully completed. Similarly, a transaction can fail if all operation in a transaction or not completed together and successfully.

Give the examples of database transaction?

  • Money transfer from one account to another account involves two operations of a transaction, that are as follows;
    • Money is deducted from account 1 and successfully transferred to account 2.
    • Money is deducted from account 1 but not successfully transferred to account 2.

Difference between Commit and Rollback:

Commit: A successful transaction is said to be committed.

Rollback:  If a transaction is not a successful transaction than it should be rolled back.

Keeping in view the above example, if money is deducted from account 1 but not successfully transferred to account 2, then rollback undo the work done in the previous transaction. It means that deducted money from account 1 is again rollback or transferred to account 1.

What are transaction properties?

Following are the transaction properties;

  • Atomicity
  • Isolation
  • Consistency
  • Durability

What is transaction atomicity?

A transaction should be atomic. It means that a transaction should be successfully completed 100%, and if any transaction is not successfully completed 100%, then it should be rollback or Undo.

  • Give an example of transaction atomicity?

    • Keeping in view the above example, if money is deducted from account 1 but not successfully transferred to account 2, then rollback undo the work done in the previous transaction. It means that deducted money from account 1 is again rollback or transferred to account 1.

What is transaction Isolation?

All transactions or operations of transactions that are performed on data and modify the data, then such kind of transactions or operations of transactions should be isolated from each other.

What is transaction consistency?

Transaction consistency means that all transactions after completing the operation leave the data in a genuine consistent state.

What is transaction durability?

According to transaction durability, all changes done by a transaction are permanent. If some changes in data are done by initial half transaction and the system is rebooted or crashed, data should be completed, when the computer starts.

Fazal Rehman Shamil
Welcome to all friends. The reason for our success is only your love for T4Tutorials. Our team is always available to answer your queries regarding any kind of confusions or discussion regarding your study and career matters. For discussion with us please join our facebook group "T4Tutorials.com". The link of the group is mentioned below. Thanks and love to all for connecting with us. We are nothing without you. Love you all.....
https://web.facebook.com/groups/2066136233601097/