AL-502 DBMS Unit 4
AL-502 DBMS Unit 4
Syllabus
UNIT IV: Transaction Processing Concepts: -Transaction System, Testing of Serializability,
Serializability of schedules, conflict & view serializable schedule, recoverability, Recovery
from transaction failures. Log based recovery. Checkpoints deadlock handling. Concurrency
Control Techniques: Concurrency Control, locking Techniques for concurrency control,
timestamping protocols for concurrency control, validation based protocol, multiple
granularity. Multi version schemes, Recovery with concurrent transaction. Introduction to
Distributed databases, data mining, data warehousing, Object Technology and DBMS,
Comparative study of OODBMS Vs DBMS. Temporal, Deductive, Multimedia, Web &
Mobile database.
Transaction
Example: Suppose an employee of bank transfers Rs 800 from X's account to Y's account.
This small transaction contains several low-level tasks:
X's Account
1. Open_Account(X)
2. Old_Balance = X.balance
3. New_Balance = Old_Balance - 800
4. X.balance = New_Balance
5. Close_Account(X)
Y's Account
1. Open_Account(Y)
2. Old_Balance = Y.balance
3. New_Balance = Old_Balance + 800
4. Y.balance = New_Balance
5. Close_Account(Y)
Operations of Transaction:
Following are the main operations of transaction:
Read(X): Read operation is used to read the value of X from the database and stores it in a
buffer in main memory.
Write(X): Write operation is used to write the value back to the database from the buffer.
Let's take an example to debit transaction from an account which consists of following
operations:
o The first operation reads X's value from database and stores it in a buffer.
o The second operation will decrease the value of X by 500. So buffer will contain 3500.
o The third operation will write the buffer's value to the database. So X's final value will
be 3500.
But it may be possible that because of the failure of hardware, software or power, etc. that
transaction may fail before finished all the operations in the set.
For example: If in the above transaction, the debit transaction fails after executing operation
2 then X's value will remain 4000 in the database which is not acceptable by the bank.
Atomicity:
By this, we mean that either the entire transaction takes place at once or doesn’t happen at
all. There is no midway i.e. transactions do not occur partially. Each transaction is
considered as one unit and either runs to completion or is not executed at all. It involves the
following two operations.
— Abort : If a transaction aborts, changes made to the database are not visible.
Suppose T has been executed till Read (Y) and then T’’ starts. As a result, interleaving of
operations takes place due to which T’’ reads the correct value of X but the incorrect value
of Y and sum computed by
T’’: (X+Y = 50, 000+500=50, 500)
is thus not consistent with the sum at end of the transaction:
T: (X+Y = 50, 000 + 450 = 50, 450) .
This results in database inconsistency, due to a loss of 50 units. Hence, transactions must
take place in isolation and changes should be visible only after they have been made to the
main memory.
Durability:
This property ensures that once the transaction has completed execution, the updates and
modifications to the database are stored in and written to disk and they persist even if a system
failure occurs. These updates now become permanent and are stored in non-volatile memory.
The effects of the transaction, thus, are never lost.
Some important points:
The ACID properties, in totality, provide a mechanism to ensure the correctness and
consistency of a database in a way such that each transaction is a group of operations that
Prof. Vineeta Shrivastava
A.P CSE
LNCTE
Database Management Systems
acts as a single unit, produces consistent results, acts in isolation from other operations, and
updates that it makes are durably stored.
ACID properties are the four key characteristics that define the reliability and consistency of
a transaction in a Database Management System (DBMS). The acronym ACID stands for
Atomicity, Consistency, Isolation, and Durability. Here is a brief description of each of these
properties:
1. Atomicity: Atomicity ensures that a transaction is treated as a single, indivisible unit of
work. Either all the operations within the transaction are completed successfully, or
none of them are. If any part of the transaction fails, the entire transaction is rolled back
to its original state, ensuring data consistency and integrity.
2. Consistency: Consistency ensures that a transaction takes the database from one
consistent state to another consistent state. The database is in a consistent state both
before and after the transaction is executed. Constraints, such as unique keys and
foreign keys, must be maintained to ensure data consistency.
3. Isolation: Isolation ensures that multiple transactions can execute concurrently without
interfering with each other. Each transaction must be isolated from other transactions
until it is completed. This isolation prevents dirty reads, non-repeatable reads, and
phantom reads.
4. Durability: Durability ensures that once a transaction is committed, its changes are
permanent and will survive any subsequent system failures. The transaction’s changes
are saved to the database permanently, and even if the system crashes, the changes
remain intact and can be recovered.
Overall, ACID properties provide a framework for ensuring data consistency, integrity, and
reliability in DBMS. They ensure that transactions are executed in a reliable and consistent
manner, even in the presence of system failures, network issues, or other problems. These
properties make DBMS a reliable and efficient tool for managing data in modern
organizations.
Advantages of ACID Properties in DBMS
1. Data Consistency: ACID properties ensure that the data remains consistent and
accurate after any transaction execution.
2. Data Integrity: ACID properties maintain the integrity of the data by ensuring that any
changes to the database are permanent and cannot be lost.
Prof. Vineeta Shrivastava
A.P CSE
LNCTE
Database Management Systems
3. Concurrency Control: ACID properties help to manage multiple transactions
occurring concurrently by preventing interference between them.
4. Recovery: ACID properties ensure that in case of any failure or crash, the system can
recover the data up to the point of failure or crash.
Disadvantages of ACID Properties in DBMS
1. Performance: The ACID properties can cause a performance overhead in the system,
as they require additional processing to ensure data consistency and integrity.
2. Scalability: The ACID properties may cause scalability issues in large distributed
systems where multiple transactions occur concurrently.
3. Complexity: Implementing the ACID properties can increase the complexity of the
system and require significant expertise and resources.
Overall, the advantages of ACID properties in DBMS outweigh the disadvantages. They
provide a reliable and consistent approach to data management, ensuring data integrity,
accuracy, and reliability. However, in some cases, the overhead of implementing ACID
properties can cause performance and scalability issues. Therefore, it’s important to
balance the benefits of ACID properties against the specific needs and requirements of
the system.
Serializability in DBMS
Serializability is a concept in database management systems (DBMS) that ensures the
correctness of concurrent transactions. A schedule (sequence of operations) is serializable if
its outcome is equivalent to the outcome of some serial execution of the same transactions.
Types of Serializability:
1. Conflict Serializability: Two schedules are conflict equivalent if one can be
transformed into the other by a series of non-conflicting swaps.
2. View Serializability: A schedule is view equivalent to a serial schedule if:
o The initial read of each transaction is the same.
o The final write of each transaction is the same.
o Intermediate operations do not change the output.
Testing Serializability
1. Conflict Serializability Test:
o Construct a precedence graph (or serializability graph):
Nodes represent transactions.
Prof. Vineeta Shrivastava
A.P CSE
LNCTE
Database Management Systems
Directed edges Ti→TjT_i \to T_jTi→Tj indicate that TiT_iTi must
precede TjT_jTj due to a conflict.
o If the graph contains no cycles, the schedule is conflict-serializable.
Steps:
o Identify conflicts (read-write, write-read, write-write).
o Draw directed edges for each conflict.
o Check for cycles in the graph.
Example:
T1: R(A), W(A)
T2: R(A), W(B)
T3: R(B), W(A)
Conflicts:
o T1→T2T1 \to T2T1→T2 (Write-Read conflict on AAA).
o T2→T3T2 \to T3T2→T3 (Write-Read conflict on BBB).
o T3→T1T3 \to T1T3→T1 (Write-Write conflict on AAA).
The precedence graph has a cycle, so SSS is not conflict-serializable.
2. View Serializability Test:
o Compare schedules based on the following:
Same read operations.
Same write operations for each data item.
Same final write for each data item.
o More complex than conflict serializability, usually less practical to test.
Key Points:
Conflict serializability is sufficient for ensuring serializability but not necessary
(some schedules are view-serializable but not conflict-serializable).
Testing conflict serializability using precedence graphs is efficient and widely used in
practice.
Ensuring serializability avoids anomalies like dirty reads, lost updates, and
uncommitted dependencies.
Conflict Serializable Schedule
A schedule is conflict serializable if it can be transformed into a serial schedule by swapping
non-conflicting operations.
Prof. Vineeta Shrivastava
A.P CSE
LNCTE
Database Management Systems
Example of a Conflict Serializable Schedule:
Consider two transactions T1T1T1 and T2T2T2:
T1T1T1: R(A),W(A)R(A), W(A)R(A),W(A)
T2T2T2: R(A),W(B)R(A), W(B)R(A),W(B)
Schedule S1
R1(A), R2(A), W1(A), W2(B)
Steps to Test Conflict Serializability:
1. Identify Conflicts:
o R1(A)) and W1(A): Same transaction, no conflict.
o R2(A) and W1(A) Read-Write conflict T2→T.
o W1(A) and W2(B)): No conflict (different data items).
2. Precedence Graph:
o Node T1 and T2.
o Directed edge T2→T1.
No cycles → Schedule S1 is conflict serializable.
Equivalent Serial Schedule:
T2→T1: Execute T2 first, then T1.
Test Method Uses precedence graph (easy to test). Comparatively harder to test.
Recoverability in DBMS
Recoverability ensures that if a transaction fails, the database can be brought back to a
consistent state. A schedule is recoverable if:
1. A transaction commits only after all transactions whose changes it read have also
committed.
2. There are no cascading rollbacks.
Recovery from Transaction Failures
When a transaction fails, the database uses recovery mechanisms to restore consistency.
Failures can be:
System Failure: Power loss, crashes, etc.
Transaction Failure: Logical errors, violations, etc.
Media Failure: Disk crashes.
Recovery Techniques:
1. Undo: Reverts changes made by uncommitted transactions.
2. Redo: Reapplies changes made by committed transactions.
Log-Based Recovery
Log-based recovery uses a log (or journal) to record all changes made to the database. The log
is stored on stable storage to ensure durability.
Aspect Details
Deadlock Prevent, detect, or resolve deadlocks using strategies like wait-for graphs
Handling or transaction rollbacks.
Shadow Paging Minimizes rollback efforts. High overhead for large updates.
Complex Data Types Supports directly (e.g., multimedia). Requires additional processing.
Performance Better for object-heavy applications. Better for structured tabular data.
Distributed DB Data distributed across nodes. Cloud systems, large-scale web services.
Mobile DB Databases for mobile use. IoT, mobile apps, real-time systems.