Table of Contents

Database transaction

Transactions in Database Systems

In the context of database systems, a Transaction is a sequence of operations performed as a single logical unit of work. Transactions ensure that a series of operations are executed in a manner that maintains data integrity and consistency. Transactions are fundamental to relational database management systems (RDBMS) and are essential for ensuring reliable data processing.

ACID Properties

Transactions are governed by the ACID (Atomicity, Consistency, Isolation, Durability) properties, which are crucial for maintaining data integrity.

Transaction Lifecycle

The lifecycle of a transaction involves several stages:

Concurrency Control

Concurrency control mechanisms are used to manage the simultaneous execution of transactions. They ensure that transactions do not conflict and that the ACID properties are maintained. Common concurrency control techniques include:

Transaction Management Challenges

Managing transactions involves several challenges:

Snippet from Wikipedia: Database transaction

A database transaction symbolizes a unit of work, performed within a database management system (or similar system) against a database, that is treated in a coherent and reliable way independent of other transactions. A transaction generally represents any change in a database. Transactions in a database environment have two main purposes:

  1. To provide reliable units of work that allow correct recovery from failures and keep a database consistent even in cases of system failure. For example: when execution prematurely and unexpectedly stops (completely or partially) in which case many operations upon a database remain uncompleted, with unclear status.
  2. To provide isolation between programs accessing a database concurrently. If this isolation is not provided, the programs' outcomes are possibly erroneous.

In a database management system, a transaction is a single unit of logic or work, sometimes made up of multiple operations. Any logical calculation done in a consistent mode in a database is known as a transaction. One example is a transfer from one bank account to another: the complete transaction requires subtracting the amount to be transferred from one account and adding that same amount to the other.

A database transaction, by definition, must be atomic (it must either be complete in its entirety or have no effect whatsoever), consistent (it must conform to existing constraints in the database), isolated (it must not affect other transactions) and durable (it must get written to persistent storage). Database practitioners often refer to these properties of database transactions using the acronym ACID.