Transaction and Its Properties
Transaction:
In database terms, a transaction is any action that reads from and/or writes to a database. A transaction may consist of a simple SELECT statement to generate a list of table contents; it may consist of a series of related UPDATE statements to change the values of attributes in various tables; it may consist of a series of INSERT statements to add rows to one or more tables, or it may consist of a combination of SELECT, UPDATE, and INSERT statements.
A transaction is a logical unit of work that must be entirely completed or entirely aborted; no intermediate states are acceptable. A successful transaction changes the database from one consistent state to another. A consistent database state is one in which all data integrity constraints are satisfied.
Transaction Properties:
Each individual transaction must display atomicity, consistency, isolation, and durability. These properties are sometimes referred to as the ACID test. When executing multiple transactions, the DBMS must schedule the concurrent execution of the transaction’s operations. The schedule of such transaction’s operations must exhibit the property of Serializability. Let’s look briefly at each of the properties.
• Atomicity requires that all operations (SQL requests) of a transaction be completed; if not, the transaction is aborted. If a transaction T1 has four SQL requests, all four requests must be successfully completed; otherwise, the entire transaction is aborted. In other words, a transaction is treated as a single, indivisible, logical unit of work.
• Consistency indicates the permanence of the database’s consistent state. A transaction takes a database from one consistent state to another consistent state. When a transaction is completed, the database must be in a consistent state; if any of the transaction parts violates an integrity constraint, the entire transaction is aborted.
• Isolation means that the data used during the execution of a transaction cannot be used by a second transaction until the first one is completed. In other words, if a transaction T1 is being executed and is using the data item X, that data item cannot be accessed by any other transaction (T2 ... Tn) until T1 ends. This property is particularly useful in multiuser database environments because several users can access and update the database at the same time.
• Durability ensures that once transaction changes are done (committed), they cannot be undone or lost, even in the event of a system failure.
• Serializability ensures that the schedule for the concurrent execution of the transactions yields consistent results. This property is important in multiuser and distributed databases, where multiple transactions are likely to be executed concurrently. Naturally, if only a single transaction is executed, serializability is not an issue.
You May Also Like: