

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Definition of Transaction in Database
A transaction consists of a series of commands executed in the database. Each command in a transaction is atomic i.e it cannot be split further into sub commands. Any command in the transaction may or may not change the structure of the database.Also, the changes required by the transaction must be made together. If this rule is not implemented, data might be lost if the system fails, power is lost or for some other reason.
A simple example of a transaction is as follows −
Harry needs to transfer Rs 100 from his account to Sally’s. This is done as a transaction. First, Harry’s account details are read and his balance is reduced by 100. This new data is saved back in Harry’s account. Next, Sally’s account details are read and her balance is increased by 100. This new data is saved back in Sally’s account.
However, it is complicated to implement a transaction in the database. In the above example, if the system crashes after the money is withdrawn from Harry’s account, it will never be added to Sally’s account. So, information is lost and Sally’s account is never updated.
Process of a Transaction
A transaction consists of a series of read and write operations. These are used to read the current value of any object, and to write back the updated value obtained after some calculations.
Read Operation
To read any database object, first it is brought into the main memory from the disk. After that, its value is copied into the required variable.
Write operation
To write any database object, the value in the memory is saved and then stored back into the disk.
- Related Questions & Answers
- States of Transaction in DBMS
- Properties of Transaction in DBMS
- What is transaction processing? Explain the properties of the transaction(DBMS)
- How changes, made in the current transaction, can be permanently recorded in MySQL database?
- Differentiate between cash transaction and credit transaction
- How changes, made in the current transaction, can be permanently eliminated from MySQL database?
- Generating result of SAP transaction automatically
- Transaction lock in MongoDB?
- What will happen to the current MySQL transaction if a START TRANSACTION command is executed in the middle of that current transaction?
- How can I update a third party database outside SAP after completing a Transaction?
- Definition and Properties of Trees
- What are the states of transaction in DBMS?
- Benefits of Transaction SE83- SAP reuse library
- How to use Boto3 to get the table definition of a database from AWS Glue Data Catalog?
- What happens to the current MySQL transaction if the session is ended in the middle of a transaction?