codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Subjects
🗄️

DBMS

23 chapters

1Intro & 3-Schema Architecture2ER Model & Diagrams3Generalization, Specialization & Aggregation4Relational Model & Codd's Rules5Relational Algebra6Tuple & Domain Relational Calculus7SQL: DDL, DML, DCL8Advanced SQL (Joins, Aggregates)9Views, Triggers & Stored Procedures10Functional Dependencies11Normalization (1NF, 2NF, 3NF)12BCNF & Lossless Decomposition13Transaction Concepts & ACID14Conflict & View Serializability15Concurrency Control & Locks162-Phase Locking (2PL)17Timestamp-Based Protocols18Indexing (Primary, Clustering)19B-Trees & B+ Trees20Hashing Techniques in DBMS21Database Recovery Techniques22NoSQL Databases Overview23Data Warehousing Concepts
SubjectsDBMS

Transaction Concepts & ACID

Updated 2026-04-22
3 min read

Transaction Concepts & ACID

When interacting with a database, you rarely execute a single SQL command in isolation. Usually, a business process requires multiple commands to be executed as a group.

A Transaction is a logical unit of processing in a DBMS that entails one or more database access operations. Usually, a transaction is initiated by a user program, where it is demarcated by statements of the form BEGIN TRANSACTION and COMMIT.

1. The classic example: Bank Transfer

Imagine transferring $100 from Account A to Account B. This involves two steps:

  1. UPDATE Accounts SET balance = balance - 100 WHERE id = 'A';
  2. UPDATE Accounts SET balance = balance + 100 WHERE id = 'B';

What happens if the server loses power exactly after Step 1 finishes, but before Step 2 starts? Account A lost $100, but Account B never got it. The money evaporated.

To prevent this catastrophic failure, the DBMS groups both steps into a single Transaction. The DBMS guarantees that either both steps happen, or neither happens.

2. The ACID Properties

To ensure the integrity of the data, the database system maintains the following four properties, famously known by the acronym ACID:

1. Atomicity (The "All or Nothing" Rule)

Either all operations of the transaction are reflected properly in the database, or none are. If a transaction fails halfway through, the database must automatically Rollback all changes made so far, returning the system to its previous state.

2. Consistency

Execution of a transaction in isolation (with no other transaction executing concurrently) must preserve the consistency of the database. For example, if there is a constraint that balance >= 0, a transaction that attempts to overdraft an account must fail and be rolled back, ensuring the database is never left in an illegal state.

3. Isolation

Even though multiple transactions may execute concurrently, the system guarantees that, for every pair of transactions $T_i$ and $T_j$, it appears to $T_i$ that either $T_j$ finished execution before $T_i$ started, or $T_j$ started execution after $T_i$ finished. Transactions should not interfere with each other or see each other's half-finished work.

4. Durability

After a transaction completes successfully (Commits), the changes it has made to the database persist, even if there are system failures (like a total power outage). The DBMS achieves this by writing the changes to a persistent transaction log on the hard drive before confirming the commit to the user.

3. Transaction States

A transaction goes through several states during its lifetime:

  • Active: The initial state; the transaction stays in this state while it is executing.
  • Partially Committed: After the final statement has been executed, but before the changes are permanently recorded to disk.
  • Committed: After successful completion. The changes are permanent.
  • Failed: After the discovery that normal execution can no longer proceed.
  • Aborted: After the transaction has been rolled back and the database restored to its prior state.


PreviousBCNF & Lossless DecompositionNextConflict & View Serializability

Recommended Gear

BCNF & Lossless DecompositionConflict & View Serializability