DBMS Unit 5 Arti Kak
DBMS Unit 5 Arti Kak
3. What is the significance of the commit and rollback operations in transaction processing?
Ans. Serializability
in the context of transaction processing refers to
the concept that ensures the consistency of a database by making
sure that the outcome of executing transactions concurrently is the
same as if the transactions were executed serially, one after the
other.
1. Discuss the concept of a deadlock in transaction processing and how it can be avoided.
1. Required Attributes:
o Mutual Exclusion: At least one resource must be held in a
non-shareable mode.
o Hold and Wait: A transaction holding at least one resource
is waiting to acquire additional resources held by other
transactions.
o No Preemption: Resources cannot be forcibly taken from
transactions holding them.
o Circular Wait: A closed chain of transactions exists, where
each transaction holds at least one resource needed by the
next transaction in the chain.
2. Variable Attributes:
o Resource Types: Different types of resources (e.g., CPU,
memory, data locks).
o Transaction Priorities: Priority levels assigned to
transactions which may affect deadlock resolution
strategies.
1. Deadlock Prevention:
o Eliminate Circular Wait: Impose a total ordering of all
resource types and ensure that each transaction requests
resources in an increasing order of enumeration.
o Resource Allocation Policies: Use policies like requiring
all resources to be requested at once (all-or-nothing) or
preempting resources from lower-priority transactions.
2. Deadlock Avoidance:
o Banker's Algorithm: Evaluate resource allocation
requests to ensure that granting them will not lead to a
deadlock.
o Wait-Die and Wound-Wait Schemes: Use transaction
timestamps to decide whether a transaction should wait or
abort when a conflict arises.
Required attributes:
Variable attributes:
User ID: Identifier for the user who initiated the transaction.
Context Information: Additional data relevant to the
transaction's state at the save point.
After the controlling site has received “Ready” message from all
the slaves –
After the controlling site has received the first “Not Ready”
message from any slave –
Variable attributes:
Required attributes:
Variable attributes:
Distinctions:
1. Logging:
o Write-Ahead Logging (WAL): Logs changes before they
are applied to the database.
o Redo Logging: Logs sufficient information to redo
changes.
o Undo Logging: Logs sufficient information to undo
changes.
2. Checkpointing:
o Consistent Checkpointing: Ensures a consistent state of
the database at the checkpoint.
o Fuzzy Checkpointing: Allows some transactions to be in
progress during the checkpoint.
3. Commit Protocols:
o Two-Phase Commit (2PC): Ensures all participants in a
distributed transaction agree before committing.
o Three-Phase Commit (3PC): Adds an additional phase to
handle network partitions.
4. Recovery Protocols:
o Immediate Update: Applies changes immediately and logs
them.
o Deferred Update: Logs changes and applies them only
after the transaction commits.
1. Explain the two-phase locking protocol in transaction processing. Discuss its benefits and
limitations.
Benefits:
Limitations:
If T1 locks A and T2 locks B, both will wait indefinitely for the other
to release the lock, causing a deadlock.
2. Explain the ACID properties of transactions in detail. Discuss why each property is
important in ensuring reliable and consistent data management.
Challenges:
Techniques:
1. Locking Protocols:
o Two-Phase Locking (2PL): Ensures that all locks are
acquired before any are released.
o Strict Two-Phase Locking: A variant where all exclusive
locks are held until the transaction commits.
2. Timestamp Ordering: Assigns timestamps to transactions to
ensure a serial order.
3. Optimistic Concurrency Control: Transactions execute
without restrictions but validate before committing.
4. Multiversion Concurrency Control (MVCC): Maintains
multiple versions of data to allow read and write operations to
occur simultaneously.
Attributes for Classification:
Required Attributes:
o Isolation Level: Degree to which the operations of one
transaction are isolated from those of other transactions.
o Lock Granularity: Size of the data item that is locked (e.g.,
row, table).
o Transaction Throughput: Number of transactions
processed in a given time period.
Variable Attributes:
o Resource Utilization: Amount of system resources used
by the concurrency control mechanism.
o Response Time: Time taken to complete a transaction.
o Scalability: Ability to maintain performance as the number
of transactions increases.
Definitions:
transactions.
Space Complexity: O(n ) for storing the graph.
2
3. Banker's Algorithm
o Definition: Simulates resource allocation for each
transaction to check for safe states.
o Performance Characteristics:
Time Complexity: O(m⋅n ), where m is the number of
2
4. Ostrich Algorithm
o Definition: Ignores deadlocks under the assumption that
they are rare and can be manually resolved.
o Performance Characteristics:
Time Complexity: O(1), as it does not perform
detection.
Space Complexity: O(1).
Scalability: Suitable for systems where deadlocks are
infrequent and manual intervention is feasible.
Each algorithm has its own criteria for classification based on:
5. Discuss the concept of transaction isolation levels (e.g., Read Uncommitted, Read
Committed, Repeatable Read, Serializable) and their impact on data consistency and
concurrency control.
1. Read Uncommitted:
o Definition: Transactions can read data that has been
modified but not yet committed by other transactions.
o Impact:
High concurrency.
Low data consistency.
Possible issues: Dirty reads, non-repeatable reads,
phantom reads.
2. Read Committed:
o Definition: Transactions can only read data that has been
committed by other transactions.
o Impact:
Moderate concurrency.
Improved data consistency compared to Read
Uncommitted.
Possible issues: Non-repeatable reads, phantom reads.
3. Repeatable Read:
o Definition: Transactions can read the same data multiple
times and get the same result, even if other transactions
modify the data in between.
o Impact:
Lower concurrency.
Higher data consistency.
Possible issues: Phantom reads.
4. Serializable:
o Definition: Transactions are completely isolated from each
other, ensuring that they execute in a serial order.
o Impact:
Lowest concurrency.
Highest data consistency.
No issues: Prevents dirty reads, non-repeatable reads,
and phantom reads.