# What Is Transaction Processing?

> Transaction processing is how a system records business events, such as a payment, an order or a seat booking, as transactions that each complete fully or not at all. Inside a database, it is the machinery that runs many transactions at once while keeping the ACID properties, through scheduling, concurrency control and recovery from failures.

Canonical: https://devsunite.com/resources/core-subjects/dbms/what-is-transaction-processing
Last updated: 2026-11-22

Subject: DBMS · Category: Transaction Processing · 7 min read

Transaction processing is how a system records real business events (a card payment, an order, a seat booking, a bank transfer) as transactions, each of which either completes fully or leaves no trace. Inside a database it is also the machinery that runs many of those transactions at the same time without one corrupting another, and keeps committed work safe through crashes. A single [database transaction](/resources/core-subjects/dbms/what-is-a-transaction) is the unit; transaction processing is everything needed to run thousands of them correctly.

## What transaction processing actually has to solve

A production database rarely handles one transaction at a time. It handles thousands running concurrently, all reading and writing overlapping data. Transaction processing is responsible for:

1. **Scheduling**: deciding the effective order in which concurrent transactions' operations get applied (see [schedules](/resources/core-subjects/dbms/schedules-and-types) and [serializability](/resources/core-subjects/dbms/serializability)).
2. **Concurrency control**: preventing transactions from interfering with each other in ways that produce wrong results (see [concurrency control](/resources/core-subjects/dbms/what-is-concurrency-control), [locking protocols](/resources/core-subjects/dbms/locking-protocols) and [deadlocks](/resources/core-subjects/dbms/deadlocks)).
3. **Recovery**: making sure a crash mid-transaction doesn't leave the database in a broken state, and that committed work is never lost (see [recoverability](/resources/core-subjects/dbms/recoverability)).

## Transaction processing systems (TPS) and their types

A transaction processing system (TPS) is the application plus database that captures and records an organization's day-to-day transactions: a bank's core banking system, a shop's point-of-sale system, an airline reservation system. Every TPS has the same basic parts:

- **Input**: the transaction data captured at the source, such as a card swipe, a form submission or a scanned barcode.
- **Processing**: validating the data and applying it as a transaction.
- **Storage**: the database that holds the records.
- **Output**: receipts, confirmations, updated balances and reports.

TPSs are usually grouped by when the processing happens:

| Type | How it works | Examples |
| --- | --- | --- |
| Batch processing | Transactions are collected over a period and processed together later | Monthly payroll, end-of-day cheque clearing, utility billing |
| Real-time (online) processing | Each transaction is processed the moment it arrives | ATM withdrawal, card payment at a shop, airline seat booking |

Batch processing is efficient for large volumes that don't need an instant answer. Real-time processing is needed when the user waits for the result, and it is where concurrency control matters most, because many users hit the same rows at once.

## The ACID properties transaction processing guarantees

Every transaction processing engine exists to keep four guarantees, the ACID properties:

| Property | What it guarantees | Typical mechanism |
| --- | --- | --- |
| [Atomicity](/resources/core-subjects/dbms/atomicity) | All of a transaction's changes happen, or none do | Undo log and rollback |
| [Consistency](/resources/core-subjects/dbms/consistency) | Each transaction moves the data from one valid state to another | Constraints and correct application logic |
| [Isolation](/resources/core-subjects/dbms/isolation) | Concurrent transactions do not see each other's unfinished work | Locking or multiversion concurrency control |
| [Durability](/resources/core-subjects/dbms/durability) | Committed changes survive a crash | Write-ahead log flushed at commit |

At the strictest isolation level (serializable), the result of running transactions concurrently is the same as running them one after another in some order. Weaker levels trade some of that guarantee for more throughput.

## Transaction states

While it runs, every transaction moves through a fixed set of states (Silberschatz, Korth and Sudarshan, *Database System Concepts*):

1. **Active**: the initial state, while its statements are executing.
2. **Partially committed**: after its final statement has executed, but before its changes are known to be durable.
3. **Committed**: after it completes successfully and its changes are permanent.
4. **Failed**: once normal execution can no longer continue, because of an error, a constraint violation or a crash.
5. **Aborted**: after it has been rolled back and the database is restored to its state before the transaction began. The system can then restart the transaction or kill it.

The possible paths are active to partially committed to committed, or active (or partially committed) to failed to aborted. Committed and aborted are the two end states; a transaction in either one is called terminated.

## OLTP vs OLAP

Transaction processing in the everyday sense is OLTP (online transaction processing). It is often contrasted with OLAP (online analytical processing), which analyses the data OLTP systems collect:

| Basis | OLTP | OLAP |
| --- | --- | --- |
| Purpose | Run day-to-day business transactions | Analyse data for reports and decisions |
| Typical operation | Short inserts, updates and lookups of a few rows | Long read-only queries aggregating many rows |
| Data | Current, detailed | Historical, often summarised |
| Schema | Normalised to avoid update anomalies | Denormalised, such as a star schema |
| Users | Customers, staff and applications | Analysts and managers |
| Measured by | Transactions per second, response time | Query response time over large data |
| Example | Bank account updates, order entry | Data warehouse sales reports |

The same company usually runs both: the OLTP database records each order, and its data is copied into a separate OLAP system (a data warehouse) for analysis, so heavy reports don't slow down live transactions.

## A worked example: the lost update

Two transactions running at the same moment against a `bank_accounts` table, both touching the same row:

```
T1: BEGIN
T2: BEGIN
T1: SELECT balance FROM bank_accounts WHERE id = 1;   -- reads 100
T2: SELECT balance FROM bank_accounts WHERE id = 1;   -- reads 100
T1: UPDATE bank_accounts SET balance = 100 - 30 WHERE id = 1;  -- intends 70
T2: UPDATE bank_accounts SET balance = 100 - 20 WHERE id = 1;  -- intends 80
T1: COMMIT
T2: COMMIT
```

If transaction processing didn't manage this correctly, both transactions would compute their new balance from the same stale `100` they each read, and whichever commits last simply overwrites the other's update, silently losing one of the two withdrawals. This failure is called a lost update, and concurrency control exists to prevent it.

At the default isolation level of PostgreSQL and MySQL, one fix is to lock the row when reading it with `SELECT ... FOR UPDATE`:

| Step | T1 | T2 |
| --- | --- | --- |
| 1 | `SELECT balance ... FOR UPDATE` reads 100, locks row 1 | |
| 2 | | `SELECT balance ... FOR UPDATE` waits for the lock |
| 3 | `UPDATE` sets balance to 70 | still waiting |
| 4 | `COMMIT` releases the lock | |
| 5 | | reads 70, sets balance to 50 |
| 6 | | `COMMIT` |

The final balance is 50, the correct result of both withdrawals. Writing the change as one statement (`UPDATE bank_accounts SET balance = balance - 30 WHERE id = 1`) has the same effect, because the second update waits for the first and then applies to the new value. Under the serializable isolation level the database instead blocks or aborts one of the conflicting transactions, and the application retries the aborted one.

## Where this matters in real systems

Every relational database's transaction processing engine (PostgreSQL's, MySQL's InnoDB, Oracle's) is one of the most heavily engineered parts of the whole system, because getting concurrency and recovery right at high throughput, under real hardware failures, is genuinely difficult. It's also why database vendors publish detailed documentation on their isolation and locking behaviour: developers building anything with concurrent write traffic need to understand these guarantees precisely, not just trust that "it's a database, so it's fine."

## What interviewers actually ask about transaction processing

- **"What is transaction processing responsible for?"** Executing transactions correctly under real concurrency: scheduling, concurrency control, and recovery from failures, so the ACID properties hold.
- **"What's a lost update, and how do you prevent it?"** Two transactions read the same value, both write a new value based on that stale read, and one overwrites the other. Locking the row with SELECT ... FOR UPDATE, an atomic UPDATE, or serializable isolation prevents it.
- **"What is the difference between OLTP and OLAP?"** OLTP runs many short transactions that change a few rows each; OLAP runs long read-only queries that aggregate large amounts of historical data.
- **"What are the states of a transaction?"** Active, partially committed, committed, failed and aborted; committed and aborted are the end states.

## Key takeaways

- Transaction processing records business events as all-or-nothing transactions and runs many of them concurrently without corrupting data.
- A TPS has input, processing, storage and output, and works in batch or in real time.
- Its job is to keep the ACID properties through scheduling, concurrency control and recovery.
- A transaction moves through active, partially committed, committed, failed and aborted states.
- OLTP handles day-to-day transactions; OLAP analyses the data they produce.

## Related

- [Previous: SQL Stored Procedures](https://devsunite.com/resources/core-subjects/dbms/sql-stored-procedures)
- [Next: Schedules and Their Types](https://devsunite.com/resources/core-subjects/dbms/schedules-and-types)
- [More in Transaction Processing: Serializability](https://devsunite.com/resources/core-subjects/dbms/serializability)
- [More in Transaction Processing: What Is Concurrency Control?](https://devsunite.com/resources/core-subjects/dbms/what-is-concurrency-control)
- [More in Transaction Processing: Problems in Concurrency Control](https://devsunite.com/resources/core-subjects/dbms/problems-in-concurrency-control)
- [More in Transaction Processing: Locking Protocols](https://devsunite.com/resources/core-subjects/dbms/locking-protocols)
- [More in Transaction Processing: Deadlocks in Transaction Processing](https://devsunite.com/resources/core-subjects/dbms/deadlocks)
- [More in Transaction Processing: Recoverability of Schedules](https://devsunite.com/resources/core-subjects/dbms/recoverability)
- [All 174 DBMS interview questions](https://devsunite.com/resources/core-subjects/dbms)
