Summarise With AI
ChatGPT
Perplexity
Claude
Gemini
Grok
ChatGPT
Perplexity
Claude
Gemini
Grok
Back

Transaction in DBMS: A Complete Guide

7 Dec 2025
8 min read

Introduction

If you have ever wondered how a banking system ensures money doesn't disappear during a transfer or how e-commerce sites maintain accurate inventory even during peak sales, the answer lies in one core concept: Transaction in DBMS.

Today’s apps are capable of dealing with milions of operations at the same ​‍​‌‍​‍‌​‍​‌‍​‍‌time. Without proper transaction management, systems would face corrupted data, double payments, failed order updates, and inconsistent states, issues that can break trust and business reliability.

By​‍​‌‍​‍‌​‍​‌‍​‍‌ going through this ultimate guide, one can understand all about a transaction in DBMS - starting from the role of ACID properties in ensuring correctness through the mechanism of concurrency control to recovery from crashes and the reason why serializability is considered the basis of consistency. The blog clarifies the whole theme in a very straightforward way, which is also suitable for exams, and it is enriched with up-to-date 2025 insights, examples, and best ​‍​‌‍​‍‌​‍​‌‍​‍‌practices.

Key Highlights of the Blog

  • A​‍​‌‍​‍‌​‍​‌‍​‍‌ Transaction in DBMS is a series of changes that are carried out as one single logical unit of work to keep the data up to standard in terms of integrity, consistency, and reliability, especially in multi-user environments. 
  • Transactions follow ACID properties: Atomicity, Consistency, Isolation, and Durability, which ensure correctness even during system failures or concurrent access.
  • Understanding transaction operations, states, schedules, concurrency control, and recovery methods is quite important to developers and DBAs who are working with databases that are necessary for the functioning of the organization. 
  • The concepts of serializability, conflict equivalence, undo/redo, WAL, checkpointing, and distributed transactions are some of the ways that data can still be correct in the case of multiple users or systems interacting ​‍​‌‍​‍‌​‍​‌‍​‍‌simultaneously. 
  • This guide breaks down everything from SQL implementation, transaction lifecycle, concurrency control, recovery mechanisms, and best practices, making it a complete reference for students, developers, and professionals.

What is a Transaction in DBMS?

A​‍​‌‍​‍‌​‍​‌‍​‍‌ transaction in Database Management System is a series of one or more database operations (like INSERT, UPDATE, DELETE, or SELECT) that together form a single, atomic unit of ​‍​‌‍​‍‌​‍​‌‍​‍‌work. A transaction ensures that all the database operations are performed atomically, meaning that either all operations are successfully completed or none are. The primary goal of transactions is to maintain the database's consistency, even when errors or system failures occur.

Real-World Example

Bank transfer:

  1. Deduct money from the Sender
  2. Add money to the Receiver

Both of these operations must either succeed together or fail together to avoid inconsistencies in the database (e.g., money being deducted but not deposited).

Note 

Modern​‍​‌‍​‍‌​‍​‌‍​‍‌ distributed systems manage transactions that go beyond microservices, cloud nodes, and clusters. ACID is still significant, but systems frequently use it together with BASE and event-driven recovery methods.

Characteristics of Transactions

A  Transaction in DBMS is defined by four key characteristics, often referred to as the ACID properties:

  • Atomicity: The feature that guarantees that every operation in the transaction is considered as one and the same unit. All operations are either executed altogether, or none is executed. When one operation fails, the whole transaction is rolled ​‍​‌‍​‍‌​‍​‌‍​‍‌back.
  • Consistency: The consistency attribute guarantees that all rules, constraints, and triggers specified in the database schema are followed, keeping the database in a valid state even after the transaction is over.
  • Isolation: Isolation ensures that the intermediate states of a transaction are invisible to other transactions. Even though transactions may execute concurrently, they should not interfere with each other, guaranteeing that the outcome of a transaction is consistent and not influenced by other concurrently executing transactions.
  • Durability: Changes made to a transaction are irreversible once it has been committed. Even in the event of a system crash, the changes made by the transaction will not be lost and will persist after recovery.

ACID Properties of Transactions

The ACID properties are fundamental to transaction management in DBMS:

1. Atomicity

Atomicity makes sure that a transaction is treated as a single unit of work. All operations within a transaction must be fully completed; otherwise, none of the changes are applied to the database.

Imagine that you are moving funds across bank accounts. Atomicity ensures that either the entire transfer (subtracting from one account and adding to the other) happens successfully, or if something goes wrong, none of the changes occur. If an error occurs halfway through, like a system crash, the database will be rolled back to its previous state, as if the transaction never happened.

Real-world Example: In an online shopping transaction, you may add items to your cart and proceed to checkout. Atomicity guarantees that no products are charged and that the inventory shows no change as if the transaction had never been undertaken in the event that the payment fails for any reason.

2. Consistency

By following all database rules, constraints, and triggers, consistency ensures that a DBMS transaction will move the database from one legitimate state to another.

Every​‍​‌‍​‍‌​‍​‌‍​‍‌ transaction should be a reflection of the database. For instance, in a system where certain rules are imposed (such as no less than zero in the account balance of a bank), a transaction has to follow those regulations. Any illegal operation that might breach such limitations is reversed, so the database is left in a stable condition at all ​‍​‌‍​‍‌​‍​‌‍​‍‌times.

Real-world Example: A company’s employee payroll system requires that an employee’s salary should never be set to a negative amount. If an error causes this to happen during a transaction, the consistency property ensures the transaction is rejected, and the database remains in a valid state without any errors.

3. Isolation

Isolation ensures that transaction in DBMS, even if executed concurrently, do not interfere with each other. Each transaction operates as if it is the only one running at that moment, without being affected by others.

This property prevents issues like dirty reads, non-repeatable reads, or phantom reads when multiple transactions are occurring simultaneously. It​‍​‌‍​‍‌​‍​‌‍​‍‌ makes sure that the modifications from a single change are not exposed to other transactions until they are finalized, thus averting the situations of interference and inconsistencies.

Real-world Example: Let's say two customers are at the same moment attempting to purchase the very last seat on a plane. By using isolation, the system guarantees that although both operations are carried out concurrently, just one will succeed in making the booking, and the second user will get a message that the seat has already been taken. Therefore, the occurrence of conflicting or wrong transactions is ​‍​‌‍​‍‌​‍​‌‍​‍‌avoided.

4. Durability

Durability ensures that, even in the case of a system failure or crash, a transaction's modifications are irreversible after it is committed.

After a transaction is completed and marked as "committed," its changes are stored permanently in the database. This ensures that if the system crashes after a transaction, the changes made by the transaction are not lost. The​‍​‌‍​‍‌​‍​‌‍​‍‌ durability feature is typically made sure of by recording the transaction logs and using methods such as database checkpoints.

Real-world Example: After an online order is placed and payment is processed, durability ensures that even if the website crashes immediately after, the order remains in the system, and the payment is recorded correctly. The transaction's outcome is guaranteed to persist.

Bottom Line

ACID ensures reliability, prevents data corruption, and maintains correctness under all conditions.

Transaction Operations in DBMS

A transaction in DBMS is composed of a series of operations that manipulate and manage data in the database. Knowing​‍​‌‍​‍‌​‍​‌‍​‍‌ these fundamental operations is necessary to understand how transactions work to keep the data they use intact, consistent, and reliable.

1. Read Operation

The read operation retrieves the value of a data item from the database. It is often the first step in a transaction, allowing the application to access current data for processing.

  • Read-Only Transaction: A transaction only involves read operations and has no side effects on the database. These matters are significant for reporting and analytics, as they do not impede data consistency.

2. Write Operation

The write operation modifies the value of a data item in the database. This can include inserting new data, updating existing data, or deleting records.

  • Data Manipulation Statements: The examples of write operations in a transaction, illustrated by SQL commands, are INSERT, UPDATE, and DELETE.

3. Commit

A commit operation finalizes a transaction, making all changes performed by the transaction permanent in the database. Once committed, the effects of the transaction are visible to other transactions and persist even in the event of a system failure.

4. Rollback

Using rollback, all changes that take place within the span of the current transaction are reversed; therefore, the database is returned to its last consistent state. The rollbacks are key to the error handling mechanism, which makes sure data integrity is not compromised due to the occurrence of partial or faulty transactions.

5. Transaction Identification and Locking

  • Transaction ID: The unique identifier is given to each transaction to trace the operations and status of the transactions.
  • Transaction Lock: Locks help in managing the simultaneous access of data items so that the conflicts are eliminated, and the attribute of isolation of transactions is upheld. 

6. Advanced Transaction Types

  • Nested Transactions: The transactions that contain sub-transactions or are under them. Each sub-transaction has the freedom to either commit or roll back, whereas the main transaction commits only if all the sub-transactions are successful.
  • Multi-Level Transactions: Transactions that span multiple layers or systems, often used in complex or distributed environments.
  • Compensating Transaction: A compensating transaction refers to a voluntary reversal of a business transaction or error correction by which the effects of the previously committed transaction are being ​‍​‌‍​‍‌​‍​‌‍​‍‌undone. 

Example

Consider a banking transaction where money is transferred from one account to another:

  1. Read the balance of the sender’s account.
  2. Write the new balance after deduction.
  3. Read the balance of the recipient’s account.
  4. Write the new balance after addition.
  5. Commit the transaction if all steps succeed; otherwise, rollback if any operation fails.

Quick Summary

Transactions consist of key operations that ensure data is processed safely and consistently.

  • Read: Gets the existing data that is needed; it is a part of a read-only transaction for analytics, which does not change the database.
  • Write: Changes the data by performing INSERT, UPDATE, or DELETE commands.
  • Commit: Permanently saves all changes made during the transaction.
  • Rollback: Reverts all changes if an error occurs, restoring the previous consistent state.
  • Transaction ID & Locks: In multi-user environments, locks offer isolation and prevent disputes, while unique IDs are used to record transactions.
  • Advanced Types:
    • Sub-transactions are implemented inside a primary transaction using nested transactions.
    • Multi-Level Transactions function at several levels of the system.
    • Compensating transactions undo the consequences of previous deeds.

States of a Transaction

A transaction in DBMS goes through different stages in its lifecycle. These stages assist in understanding the progress as well as the success or failure of a transaction:

1. Active

In the Active state, the transaction is in progress and executing its operations, such as reading, writing, updating, or deleting data. At this point, the changes made by the transaction are not yet permanent, and the transaction is still being processed.

2. Partially Committed

Once all operations of the transaction have been executed, the system enters the Partially Committed state. Here, the transaction has finished its operations but has not yet finalized or made permanent in the database.

3. Committed

The Committed state indicates that the  Transaction in DBMS has successfully completed, and all its changes have been permanently applied to the database. After this, the effects of the transaction are visible to other transactions, and no rollback is possible.

4. Failed

A transaction in the Failed state is essentially a failure or error that occurs during the execution of that transaction; hence, it cannot proceed any further. Such a transaction is stuck in the failure state, and no changes are made to the database.

5. Aborted/Terminated

The Aborted/Terminated state shows that the transaction has been rolled back due to an error or user intervention. The undoing of the transaction is complete; all changes made by the transaction are reversed, and the database is restored to its state before the transaction was initiated.

Note:

A​‍​‌‍​‍‌​‍​‌‍​‍‌ transaction goes through various stages that show its advancement and result: Initially, it is Active, after the completion of operations, it becomes Partially Committed, if the transaction is successful, it will be Committed, otherwise, it moves to Failed and then Aborted in case of errors. These condition changes give the local management system the means to keep control, guarantee data consistency, and deal with the fallback situation if there is a ​‍​‌‍​‍‌​‍​‌‍​‍‌malfunction.

How to Define and Implement Transactions in SQL

In​‍​‌‍​‍‌​‍​‌‍​‍‌ relational database management systems, a Transaction in DBMS is accomplished by using certain SQL commands that dictate how operations are grouped, carried out, committed, or reversed. These commands make sure that every stage of a transaction is in line with ACID properties and the data remains ​‍​‌‍​‍‌​‍​‌‍​‍‌consistent.

Key SQL Commands for Transaction Management

1. BEGIN TRANSACTION / START TRANSACTION

This is the point where a transaction is marked to start. Any operations made after this point are considered part of the same transaction. 

2. COMMIT

It records permanently all the modifications that have been made during the transaction. If a commit is made, the transaction will be ​‍​‌‍​‍‌​‍​‌‍​‍‌irreversible. 

3. ROLLBACK

Reverts every modification made to the active transaction. It is applied when a mistake happens or when processes need to be stopped in order to preserve consistency.

Example: Successful Transaction

BEGIN TRANSACTION;

UPDATE accounts SET balance = balance - 100 WHERE account_id = 1;

UPDATE accounts SET balance = balance + 100 WHERE account_id = 2;

COMMIT;

Here, both updates succeed, so the transaction commits and changes become permanent.

Example: Transaction with Error Handling

BEGIN TRANSACTION;

UPDATE accounts SET balance = balance - 100 WHERE account_id = 1;

-- Error occurs here

ROLLBACK;

If any step fails, the entire transaction is rolled back, ensuring no partial updates affect the database.

Summary 

  • SQL transactions combine multiple operations into one unit that is still reliable. 
  • The commands BEGIN, COMMIT, and ROLLBACK are used to execute the transaction safely and recover from errors. 
  • With the help of a transaction, it is made certain that either all the operations are successful or in case of failure, the database will be left in its previous, consistent ​‍​‌‍​‍‌​‍​‌‍​‍‌state.

Transaction Lifecycle:

The transaction lifecycle in DBMS represents the different stages that a transaction goes through from the moment it is initiated until it is completed. The stages are the means by which the database keeps track of the progress, identifies the points of failure, and also makes sure that recovery and consistency are done correctly.

1. Active

The transaction begins execution. It makes use of the database in operations such as read, write, update, or delete. Changes, if any, are not permanent at this ​‍​‌‍​‍‌​‍​‌‍​‍‌point.

2. Partially Committed

All operations have been executed successfully, but the final commit has not yet occurred. The database is prepared to make changes permanent.

3. Committed

The transaction completes successfully, and all its changes are permanently stored in the database. From this point on, there is no rollback.

4. Failed

As a result of an error or system issue, the transaction is unable to complete. The transaction cannot be continued in its current state.

5. Aborted

The system rolls back the transaction due to a failure or manual cancellation. Any changes that were made during the aborted transaction are reverted, thus the database is restored to the previously consistent state.

6. Terminated

The transaction comes to a formal end. It is after either a commit (successful completion) or a rollback (aborted completion) that this happens. 

Summary 

  • The transaction lifecycle offers a well-defined path from performing to either finishing or going back. 
  • Every stage safeguards the database from becoming inconsistent when, for instance, errors are encountered. 
  • Knowing these states aids in locating bugs, recovery planning, and ensuring ACID compliance.

Types of Transactions

A transaction in DBMS can be divided into different categories based on the scope and ​‍​‌‍​‍‌​‍​‌‍​‍‌complexity:

1. Local Transactions

Local transactions in DBMS are operations that occur within a single database. They are relatively simple and typically involve straightforward tasks such as inserting, updating, or deleting records within that database. Since they involve just one system, the management of these transactions is less complex, and issues like coordination between multiple databases do not arise.

2. Distributed Transactions

Distributed transactions involve multiple databases, often located on different servers or networks. These transactions require coordination between the databases to ensure that they all commit or roll back as a unified operation. 

Distributed transactions frequently rely on protocols like the two-phase commit to guarantee that the transaction succeeds or fails across all participating databases simultaneously due to the difficulty of managing many systems and ensuring consistency.

Importance of Transactions in DBMS

Transactions are the core elements that help a database system to be accurate, reliable, and stable. They are the ones who make sure the data is consistent, even if several operations or users are running the system at the same time.

1. Data Integrity

Transactions are the means through which data integrity is guaranteed. They do this by encapsulating the related changes in one unit; thus, they make sure that no partial updates occur and the data remains consistent, even in a situation of heavy user load.

2. System Recovery

In the case of a system crash, hardware failure, or an error, transactions are the means by which the system can be put back into a consistent state. The different stages of the log, checkpoint, undo, and redo ensure that the data that has been committed is saved, and the operations that were not completed are rolled back safely.

3. Concurrency Control

Transactions achieve concurrency control by isolating the operations that are going to be performed. By doing this, they avoid conflicts such as dirty reads, lost updates, or data inconsistency; hence, a large number of users can work simultaneously without the risk of these problems.

Why it matter?

The sectors such as banking, e-commerce, finance, and healthcare, which are data-driven, can not do without accurate and fail-proof data. The correct handling of transactions is the thing that makes trust, reliability, and operations without interruption possible.

Tip

Always design transactions to be short, atomic, and well-controlled. This reduces lock contention, improves performance, and minimizes the risk of conflicts in high-traffic systems.

Concurrency Control in Transactions

Concurrency control ensures that multiple transactions can execute simultaneously without causing data inconsistencies. There are several techniques used in concurrency control:

  • Locking Protocols: Locking mechanisms prevent conflicting operations on the same data. For example, a read lock prevents a write lock, and a write lock prevents any other read or write operations.
  • Timestamp Ordering: In this approach, transactions are assigned timestamps, and the DBMS ensures that the order of execution follows these timestamps, preventing conflicts.
  • Optimistic Concurrency Control: This technique assumes minimal conflicts. Transactions are executed without locks, and only at the end is the consistency of the transaction checked before committing.

Transaction Schedules and Serializability

In​‍​‌‍​‍‌​‍​‌‍​‍‌ the case of multiple transactions being carried out in a database system, the operations of these transactions can interleave in different ways. The sequence of these operations is known as a schedule. Knowledge of schedules and the idea of serializability is a must for keeping the data consistent in a database, in particular, in situations where transactions are run ​‍​‌‍​‍‌​‍​‌‍​‍‌concurrently.

What is a Transaction Schedule?

A schedule is a sequence that shows the chronological order in which concurrent transaction instructions are carried out. In general, schedules fall into:

  • Serial Schedule: Each transaction is executed from start to finish without any interleaving of operations from other transactions. This approach guarantees database consistency but can reduce system throughput due to a lack of concurrency.
  • Non-Serial Schedule: In such a case, activities of several transactions are mixed. As a result, the system throughput and resource utilization are enhanced, but there is a danger of the database becoming inconsistent if the risk is not controlled properly.

Serializability: The Gold Standard for Concurrent Transactions

Serializability is a key concept that ensures the outcome of a non-serial schedule is equivalent to some serial schedule. In other words, even though transactions are interleaved, the final state of the database is as if the transactions were executed one after another. This is essential for maintaining database consistency in the presence of concurrent transactions.

Types of Serializability

  • Conflict Serializability: In case a schedule can be changed to a serial one by the consecutive interchange of non-conflicting operations (which do not refer to the same data item or at least one is a read), it is conflict ​‍​‌‍​‍‌​‍​‌‍​‍‌serializable.
  • View Serializability: A schedule is view serializable if transactions in the schedule perform the same reads and writes as in some serial schedule, even if the order of operations differs.

Equivalence Relations and Isolation Levels

  • Equivalence Relation: Two schedules are considered equivalent if they produce the same result and preserve database consistency, even if their operations are ordered differently.
  • Isolation Level: The extent to which the activities of one transaction are kept separate from the activities of other concurrently running transactions. A higher isolation level lowers the risk of anomalies but can also reduce system throughput. 

Importance of Serializability

Serializability is the basis of the ACID properties, particularly isolation and consistency. By preventing concurrent transactions from interfering and thus producing wrong results, serializability keeps the database reliable and correct.

System Throughput and Practical Considerations

Although serial schedules always ensure safety, they limit the performance of the system. Non-serial schedules, along with suitable concurrency control and isolation levels, make a compromise between system throughput and database consistency.

Why it matters:

Schedule equivalence ensures that concurrent execution is the same as sequential one, thus consistency and stability in multi-user environments are maintained.

Schedule Equivalence in DBMS

In database systems, the interleaving of operations of concurrently executed transactions may differ, thus resulting in various schedules. To be sure that the system is working correctly, it is necessary to recognize if different schedules are equivalent, i.e. if they yield the same result and keep the database consistent. The most important ones are the three forms of schedule equivalence in DBMS:

1. Result Equivalence

Two schedules are result equivalent if the final state of the database after their execution is the same for the same initial data values. Nevertheless, this type of equivalence is seldom enough in theory, as it may not guarantee consistency for all possible data values or cases.

2. View Equivalence

View equivalence considers the way data is read and written by transactions. Two schedules are viewed as equivalent if:

  • For every read operation, the value read is the same in both schedules (either the initial value or the value written by the same transaction).
  • The final write on each data item is performed by the same transaction in both schedules.

A schedule is view serializable if it is view equivalent to some serial schedule.

3. Conflict Equivalence

Conflict equivalence focuses on the order of conflicting operations, those that:

  • Belong to different transactions,
  • Access the same data item,
  • And at least one is a write operation.

Two schedules are conflict equivalent if the order of all conflicting operation pairs is the same in both. If a schedule is in conflict with a serial schedule, it can be serialized.

Related Concepts

  • Equivalence Schedules: Schedules that are equivalent under one of the above criteria.
  • Conflicting Operations: Operations that may affect each other’s outcome due to accessing the same data item.
  • Isolation Level: Determines how and when the changes made by one transaction become visible to others, affecting the potential for equivalence.
  • Compensating Transaction: A transaction that undoes the effects of a previous transaction, often used in advanced recovery scenarios.

Why Schedule Equivalence Matters?

Knowing​‍​‌‍​‍‌​‍​‌‍​‍‌ schedule equivalence is the main way database systems can safely interleave transactions for improved performance, and at the same time be sure that the final outcome is the same as if transactions had been executed one after another. In multi-user setups, this is crucial for keeping consistency and ​‍​‌‍​‍‌​‍​‌‍​‍‌stability.

Transaction Management and Recovery

Transaction​‍​‌‍​‍‌​‍​‌‍​‍‌ management covers an array of operations that includes logging, commit protocols, and rollback mechanisms. These are the functions of each of them:

  • Logging: Database systems keep a log of all transactions to ensure that, in the event of a failure, the system can either commit or roll back transactions based on the log entries.
  • Commit Protocols: On completion of the transaction, these protocols guarantee that all the modifications carried out by a transaction are updated in the database.
  • Rollback Mechanisms: When the transaction is troubled or it is aborted, rollback mechanisms reverse the changes made in the transaction, thus keeping the database in a consistent state.

In distributed systems, the transaction coordinator is a component that handles the commit and rollback operations in different databases, thereby ensuring atomicity and consistency.

Bottom Line

Transaction management and recovery are the mechanisms that make every database action reliable, traceable, and reversible if necessary. It is part of the same system that logging, commits, and rollbacks are, which is aimed at protecting the system from failures and keeping data consistent, even in distributed environments.

Transaction Recovery Techniques in DBMS

The transaction recovery methods that are implemented guarantee that the database will return to a consistent and correct state, even in the case of a system crash, power failure or software error. These methods cooperate with logs, checkpoints, undo/redo operations, and update strategies to uphold durability and consistency, which are the two pillars of the ACID properties. 

1. Checkpointing

A checkpoint is a snapshot of the current database state.
During recovery, instead of scanning the entire log from the beginning, the DBMS starts recovery from the latest checkpoint.

Why checkpoints matter

  • Checkpoints​‍​‌‍​‍‌​‍​‌‍​‍‌ lessen the recovery time since they provide the system with a quite recent stable point from which to start the recovery, rather than going through the whole log. 
  • Firstly, they work to delete those log entries that are old and redundant; thus, the recovery process remains efficient and the log size is kept at a reasonable ​‍​‌‍​‍‌​‍​‌‍​‍‌level.

2. Undo Operation

Undo reverses the effects of uncommitted transactions.

Used when:

  • A transaction malfunctions and consequently cannot be completed.
  • The system crashes while the transaction is still in progress.
  • A user deliberately rolls back a change to the transaction by cancelling its effects.

Example:

If a transaction of ₹5,000 withdrawal from an account had not been committed, then undo would make the balance the same as it was ​‍​‌‍​‍‌​‍​‌‍​‍‌initially. 

3. Redo Operation

Redo​‍​‌‍​‍‌​‍​‌‍​‍‌ essentially performs the same operations of the committed transactions again from the log to make them durable.

Used when:

  • A system crashes after commit but before changes are written to disk
  • The recovery system must ensure committed transactions aren’t lost

Example:

In case a transaction transferred ₹2,000 and was successfully committed, but a crash occurred before writing to the disk, redo redoes the transfer. 

4. Deferred Update Approach

In Deferred Update, all updates of a transaction are stored in logs but not applied to the database until the transaction commits.

Characteristics

  • No changes are written to the database until the transaction commits, ensuring that uncommitted updates never affect the actual data.
  • Only redo operations are required during recovery because all updates are applied after the commit.
  • Maintaining consistency becomes easier since the database is never altered by incomplete or failed transactions.

Use Case:
Systems where committing is infrequent or logging is cheap.

5. Immediate Update Approach

In Immediate Update, the data is changed in the database prior to the commit of the transaction.

Characteristics

  • During​‍​‌‍​‍‌​‍​‌‍​‍‌ recovery, it is possible that both undo and redo operations will be needed as updates are made prior to the commit.
  • In accordance with the Write-Ahead Logging (WAL) principle, which is aimed at providing data safety and consistency, all modifications have to be first logged before they are physically applied to the ​‍​‌‍​‍‌​‍​‌‍​‍‌database. 

Use Case:
High-speed OLTP systems where early writing reduces bottlenecks.

6. Shadow Paging

Shadow paging avoids logs entirely.

How it works:

  • Two copies of the database pages exist:
    • Shadow page (original, safe version)
    • Current page (working version)
  • Updates are applied to current pages
  • On commit → current pages replace shadow pages
  • On failure → discard current pages and revert to shadow pages

Benefits

  • No undo or redo logs are required, simplifying recovery.
  • It is a very fast recovery because the system can go back to the stable shadow copy almost immediately.  

Limitations

  • The method is not appropriate for large databases because of the high cost of keeping duplicate page copies.
  • The operation of page copying makes the system slow to a great extent, especially if there are a lot of ​‍​‌‍​‍‌​‍​‌‍​‍‌updates. 

7. Savepoints

A savepoint is a marker inside a transaction that allows partial rollback.

Example:

BEGIN; UPDATE A; SAVEPOINT sp1; UPDATE B; ROLLBACK TO sp1; -- Undo only update on B COMMIT;

Useful in:

  • Complex transactions
  • Long-running processes
  • Scenarios needing fine-grained control

8. Logs (Write-Ahead Logging – WAL)

The log file is the heart of recovery.

A log records:

  • Transaction start
  • All updates (before and after values)
  • Commit/rollback actions

WAL Rule

Logs must be written to disk before the actual data is updated.

This ensures:

  • Undo can restore previous values
  • Redo can reapply committed values

Quick Note 

Modern DBMS like PostgreSQL, Oracle, and MySQL are still very much dependent on WAL and checkpoints, but cloud-native systems have added:

  • Distributed logs
  • Parallel recovery
  • SSD-optimized checkpoint intervals

This is what makes the recovery process not only faster but also more reliable, even when there are huge distributed workloads.

Bottom Line

Recovery techniques ensure that the database never loses committed data and never applies invalid or partial transactions, regardless of failures. They safeguard the durability and consistency of every transaction.

Best Practices for Transaction Management

By effectively handling transactions, you may also employ the following excellent tactics:

  • Keep transactions short: The over-extended transactions raise the risk of conflicts and lower the system's throughput.
  • Choose appropriate isolation levels: Adjust isolation levels according to the precise needs of the application, thus giving a balance between performance and data consistency.
  • Handle errors appropriately: Be sure to always execute error handling and rollback activities so that database states remain consistent.
  • Monitor transaction performance: Transaction efficiency should be periodically checked and increased if necessary so that the database is always in a state of responsiveness and reliability. 

Conclusion

Transaction in DBMS are the lifeline of the DBMS, without which data integrity, consistency, and reliability would not be possible. These systems can still handle the complex, concurrent, and safe transactions efficiently by obeying the ACID principles, using appropriate concurrency control methods and recovery mechanisms. 

Understanding transactions is quite essential for database administrators, developers, and anyone who is involved in the creation and management of data-driven applications.

Points to Remember

  • Transactions are the key to reliable and consistent database operations through their ACID properties. 
  • Commit and rollback act as data protectors in case of errors or concurrent access. 
  • Concurrency control and serializability ensure that there are no conflicts when several users perform operations at the same time. 
  • Recovery means, like logging, checkpointing helps the system regain the lost ground after crashes. 
  • Having knowledge about transaction states and their lifecycle is very important when it comes to the design of robust ​‍​‌‍​‍‌​‍​‌‍​‍‌applications.

Frequently Asked Questions

1. What is a transaction in DBMS?

A series of database activities carried out as a single unit of work is called a transaction in DBMS. It guarantees data consistency and integrity by ensuring that either all of the transaction's activities are correctly executed or none of them are.

2. What are the ACID properties of transactions?

Atomicity, Consistency, Isolation, and Durability are the four characteristics of ACID. These characteristics provide dependable transaction processing, preserve database integrity, and gracefully handle system faults.

3. How does the isolation property work in transactions?

The isolation property limits the intermediate state of a transaction from other transactions. By doing so, it prevents errors such as dirty reads, where a transaction reads changes that are not yet committed by another, thus ensuring that each transaction yields consistent results.

4. What is the role of the COMMIT and ROLLBACK commands?

With the COMMIT command, the transaction is completed, and all changes are made permanent, whereas the ROLLBACK command cancels all modifications that were made during the transaction in case of an error or a failure, thereby allowing the database to regain its previous state.

5. What are the different states of a transaction?

The transaction states in the DBMS are: Active, Partially Committed, Committed, Failed, and Aborted. These states are used to monitor the transaction's progress as well as its completion, thus they enable correct error handling and recovery.

6. What is the difference between local and distributed transactions?

Local transactions are the ones that involve changes to a single database, while distributed transactions have to do with the changes that are made on several databases. Coordinating distributed transactions is necessary in order to be able to guarantee atomicity and consistency in all the databases that take part.

7. Why are transactions important in DBMS?

Transactions constitute the main source of data integrity; they enable concurrent access, and they also make up the system recovery in case of a failure. They go a long way towards keeping data accurate, consistent, and reliable, which is particularly important in the likes of banking applications, e-commerce, and inventory ​‍​‌‍​‍‌​‍​‌‍​‍‌management.

Read More Articles

Chat with us
Chat with us
Talk to career expert