DBMS-Chapter 12
DBMS-Chapter 12
Read-Only Transaction
If the database operations in a transaction does not
update the database but only retrieve the data, the
transaction is called a read-only transaction.
Read-write Transaction
Database operations in a transaction that update the
database.
Database is represented as a collection of named
data items.
The size of the data item is called its Granularity.
A data item can be a database record, whole disk
block, or even a single attribute.
Each data item has a unique name.
Basic database operations that a transaction can
include:
read_item(X): Reads a database item named X
into a program variable. To simplify our notation,
we assume that the program variable is also
named X.
write_item(X): Writes the value of program
variable X into the database item named X.
read_item(X) command includes the following
steps:
1. Find the address of the disk block that
contains item X.
2. Copy that disk block into a buffer in main
memory (if that disk block is not already in
some main memory buffer).
3. 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).
Many transactions may execute concurrently,
access and update the same db items.
Ifuncontrolled, result in some problems (ie,
inconsistent database)
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.
Example:
The Temporary Update (or Dirty Read) Problem
This occurs when one transaction updates a
database item and then the transaction fails for some
reason.
Example:
Incorrect Summary Problem
Consider a situation, where one transaction is
applying the aggregate function on some records
while another transaction is updating these records.
The aggregate function may calculate some values
before the values have been updated and others
after they are updated.
The Unrepeatable Read Problem: