0% found this document useful (0 votes)
2 views

Chapter 7 - Transaction Processing Concepts

The document provides an overview of transaction processing concepts in database management systems, detailing the definition of transactions, transaction states, and the importance of properties like atomicity, consistency, isolation, and durability. It also discusses concurrency control issues, the classification of schedules, and the support for transactions in SQL. Key topics include transaction boundaries, buffer management, and the implications of concurrent execution on database integrity.

Uploaded by

diro bayisa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter 7 - Transaction Processing Concepts

The document provides an overview of transaction processing concepts in database management systems, detailing the definition of transactions, transaction states, and the importance of properties like atomicity, consistency, isolation, and durability. It also discusses concurrency control issues, the classification of schedules, and the support for transactions in SQL. Key topics include transaction boundaries, buffer management, and the implications of concurrent execution on database integrity.

Uploaded by

diro bayisa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Exit Exam Tutorial

Part 2: Fundamental Database Management Systems


Episode 7: Transaction Processing Concepts
2.7 Transaction Processing
Concepts
2.7.1 Introduction to Transaction Processing
- Transaction: Logical unit of database processing that
includes one or more access operations (read -retrieval,
write - insert or update, delete).
- Transaction boundaries: Any single transaction in an
application program is bounded with Begin and End
statements.
- An application program may contain several transactions
separated by the Begin and End transaction boundaries.
2.7 Transaction Processing
Concepts
 read_item(X) command includes the following steps:
- Find the address of the disk block that contains item X.
- Copy that disk block into a buffer in main memory (if that
disk block is not already in some main memory buffer).
- Copy item X from the buffer to the program variable named
X.
 write_item(X) command includes the following steps:
- Find the address of the disk block that contains item X.
- Copy that disk block into a buffer in main memory (if that
disk block is not already in some main memory buffer).
- Copy item X from the program variable named X into its
correct location in the buffer.
- Store the updated block from the buffer back to disk (either
immediately or at some later point in time).
2.7 Transaction Processing
Concepts
 The DBMS maintains a number of buffers in the main
memory that holds database disk blocks which contains the
database items being processed.
- When this buffers are occupied and
- If there is a need for additional database block to be copied
to the main memory
 Some buffer management policy is used to choose for
replacement but if the chosen buffer has been modified, it
must be written back to disk before it is used.
2.7 Transaction Processing
Concepts
2.7.2 Transaction and System Concepts
- A transaction is an atomic unit of work that is either completed
in its entirety or not done at all.
- For recovery purposes, the system needs to keep track of when
the transaction starts, terminates, and commits or aborts.
 Transaction states:
- Active state: indicates the beginning of a transaction
execution.
- Partially committed state shows the end of read/write
operation but this will not ensure permanent modification on
the data base.
- Committed state: ensures that all the changes done on a record
by a transition were done persistently.
- Failed state: happens when a transaction is aborted during its
active state or if one of the rechecking is fails.
- Terminated State: corresponds to the transaction leaving the
system.
2.7 Transaction Processing
Concepts
- T in the following discussion refers to a unique transaction-
id that is generated automatically by the system and is used
to identify each transaction:
 Types of log record:
- [start_transaction,T]: Records that transaction T has started
execution.
- [write_item,T,X,old_value,new_value]: Records that
transaction T has changed the value of database item X
from old_value to new_value.
- [read_item,T,X]: Records that transaction T has read the
value of database item X.
- [commit,T]: Records that transaction T has completed
successfully, and affirms that its effect can be committed
(recorded permanently) to the database.
- [abort,T]: Records that transaction T has been aborted.
2.7 Transaction Processing
Concepts
2.7.3 Desirable Properties of Transactions
- Atomicity: A transaction is an atomic unit of processing; it is
either performed in its entirety or not performed at all.
- Consistency preservation: A correct execution of the
transaction must take the database from one consistent
state to another.
- Isolation: A transaction should not make its updates visible
to other transactions until it is committed; this property,
when enforced strictly, solves the temporary update
problem and makes cascading rollbacks of transactions
unnecessary.
- Durability or permanency: Once a transaction changes the
database and the changes are committed, these changes
must never be lost because of subsequent failure.
2.7 Transaction Processing
Concepts
2.7.4 Transaction Processing
- Single-User System: At most one user at a time can use the
database management system.
- Multiuser System: Many users can access the DBMS
concurrently.
- This is achieved by multiprogramming, which allows the
computer to execute multiple programs /processes at the
same time.
 Concurrency
- Interleaved processing: Concurrent execution of processes
is interleaved in a single CPU using for example, round robin
algorithm.
2.7 Transaction Processing
Concepts
Advantages:
- Keeps the CPU busy when the process requires I/O by
switching to execute another process rather than remaining
idle during I/O time and hence this will increase system
throughput (average no. of transactions completed within a
given time)
- Prevents long process from delaying other processes
(minimize unpredictable delay in the response time).
- Parallel processing: If Processes are concurrently executed
in multiple CPUs.
2.7 Transaction Processing
Concepts
Problems of Concurrent Sharing
 Why Concurrency Control is needed. Three cases:
i. The Lost Update Problem: This occurs when two transactions
that access the same database items have their operations
interleaved in a way that makes the value of some database item
incorrect.
ii. The Temporary Update (or Dirty Read) Problem: This occurs
when one transaction updates a database item and then the
transaction fails for some reason.
 The updated item is accessed by another transaction before it
is changed back to its original value.
iii. The Incorrect Summary Problem: If one transaction is
calculating an aggregate summary function on a number of
records while other transactions are updating some of these
records, the aggregate function may calculate some values
before they are updated and others after they are updated.
2.7 Transaction Processing
Concepts
2.7.5 Concepts of Schedules and Serializability
- Transaction schedule or history: When transactions are
executing concurrently in an interleaved fashion, the order
of execution of operations from the various transactions
forms what is known as a transaction schedule (or history).
- A schedule S of n transactions T1, T2, …, Tn:
- It is an ordering of the operations of the transactions
subject to the constraint that, for each transaction Ti that
participates in S, the operations of T1 in S must appear in
the same order in which they occur in Ti.
- Note, however, that operations from other transactions Tj
can be interleaved with the operations of Ti in S.
2.7 Transaction Processing
Concepts
 Two operations in a schedule are said to be conflict if they
satisfy the following conditions.
- They belongs to different transaction
- They access the same data item X
- At least one of the operation is a write_Item(X)
2.7 Transaction Processing
Concepts
Schedules classified by recoverability:
 Recoverable schedule:
- One where no committed transaction needs to be rolled
back.
- A schedule S is recoverable if no transaction Tj in S commits
until all transactions Ti that have written an item that Tj
reads have committed.
- Examples:
 Sc: r1(X); w1(X); r2(X); r1(Y);w2(x);c2;a1; not recoverable
 Sd: r1(X); w1(X); r2(X); r1(Y); w2(X);w1(Y); c1; c2;
recoverable
 Se: r1(X); w1(X); r2(X); r1(Y); w2(x) ; w1(Y); a1; a2;
recoverable
2.7 Transaction Processing
Concepts
 Cascadeless schedule:
- One where every transaction reads only the items that are
written by committed transactions.
- Examples:
 Sf: r1(X); w1(X); r1(Y); c1; r2(X); w2(X);w1(Y); c2;
 Strict Schedules:
- A schedule in which a transaction can neither read or write
an item X until the last transaction that wrote X has
committed/aborted.
- Examples:
 Sg: w1(X,5) ; c1; w2(x,8)
2.7 Transaction Processing
Concepts
 Characterizing Schedules based on Serializability:
- The concept of Serializable of schedule is used to identify
which schedules are correct when concurrent transactions
executions have interleaving of their operations in the
schedule.
 Serial schedule:
- A schedule S is serial if, for every transaction Ti
participating in the schedule, all the operations of Ti are
executed consecutively in the schedule.
- Otherwise, the schedule is called non-serial schedule.
2.7 Transaction Processing
Concepts
 Serializable schedule:
- A schedule whose effect on any consistent database
instance is identical to that of some complete serial
schedule over the set of committed transactions in S.
- A nonserial schedule S is serializable , is equivalent to say
that it is correct to the result of one of the serial schedule.
 Result equivalent:
- Two schedules are called result equivalent if they produce
the same final state of the database
- Two types of equivalent schedule: Conflict and view.
2.7 Transaction Processing
Concepts
2.7.6 Transaction Support in SQL
- A single SQL statement is always considered to be atomic.
- Either the statement completes execution without error or
it fails and leaves the database unchanged.
- Every transaction has three characteristics: Access mode,
Diagnostic size and isolation.
 Access mode:
- READ ONLY or READ WRITE
- If the access mode is Read ONLY , INSERT, DELET , UPDATE
& CREATE commands cannot be executed on the database.
- The default is READ WRITE unless the isolation level of
READ UNCOMITTED is specified, in which case READ ONLY
is assumed.
2.7 Transaction Processing
Concepts
- Diagnostic size n, specifies an integer value n, indicating the
number of error conditions that can be held simultaneously
in the diagnostic area.
- Isolation level can be READ UNCOMMITTED, READ
COMMITTED, REPEATABLE READ or SERIALIZABLE.
- The default is SERIALIZABLE.
- SET TRANSACTION READ WRITE | READ ONLY
ISOLATION LEVEL REPEATABLE READ | READ
UNCOMMITTED | SERIALIZABLE;
- BEGIN TRANSACTION statement and end with the
COMMIT or ROLLBACK statement.
2.7 Transaction Processing
Concepts
Special Thanks to the publisher and author with:
2.7 Transaction Processing
Concepts
TOPICS AND THE CONCEPTS:
What is Transaction?
Transaction and System Concepts
Transaction Processing
Conflicting Equivalent
Recoverability of Schedules
Serializability of Schedules
Transaction Support in SQL

REFERENCES:
Fundamental Database Management Systems (6th Edition) by Ramez Elmasri, Shamkant B. Navaathe
Database Systems: A Practical Approach to Design, Implementation, and Management (6th Edition) by
Thomas Connolly, Carolyn Begg

PRESENTED BY:
Mohammed Nebil

HISTORY OF THE PROGRAMMING:


Boyce Codd

SPECIAL THANKS:
Digital Library of Educations
Federal Democratic Republic of Ethiopia, Ministry of Educations
Ethiopian Education Short Note

You might also like