DBMS Chap-5
DBMS Chap-5
6] What are the types of errors that may cause a transaction to fail?
1) such as incorrect input or insufficient data to complete the transaction.
Syntax Errors: These happen when the DBMS cannot execute a transaction due to syntax
issues, often resulting in the system aborting the transaction.
Deadlocks: Situations where two or more transactions are waiting indefinitely for each other
to release resources, causing the transaction to fail.
2)System Crash/ Failure:
Hardware Issues: Failures due to hardware problems like power supply disruptions or
hardware malfunctions.
Software Issues: Errors caused by operating system bugs or database software issues.
3)Disk Failure:
Hardware Failure: Disk failures due to bad sectors, corruption, or insufficient resources.
10] Explain:
i) ACID Properties: ACID is an acronym representing the four essential properties of
database transactions that ensure data integrity and reliability:
Atomicity: Ensures that a transaction is treated as a single unit of work.
Either all operations in the transaction are executed successfully, or none are executed
(rollback on failure).
Consistency: Guarantees that a transaction takes the database from one consistent state to
another.
Ensures adherence to constraints like foreign keys and unique keys.
Isolation: Ensures that concurrent transactions do not interfere with each other.
Each transaction appears as if it is executed sequentially, preventing issues like dirty reads or
non-repeatable reads.
Durability: Ensures that once a transaction commits, its changes are permanently stored in
the database.
ii) Timestamp-Based Concurrency Control: Timestamp-based concurrency control is a
method used to manage concurrent transactions by assigning unique timestamps to each
transaction based on their start time. It ensures serializability by ordering transactions
according to their timestamps.
Key Features:
Timestamp Assignment: Each transaction is assigned a unique timestamp when it starts.
Older transactions (with smaller timestamps) are given priority over newer ones.
Read and Write Rules:
Read Rule: A transaction can read a data item only if no newer transaction has written to it.
Write Rule: A transaction can write to a data item only if no newer transaction has read or
written to it.
Conflict Resolution: If a transaction violates the timestamp order, it is aborted and restarted
with a new timestamp.
Advantages:
Prevents deadlocks as transactions are strictly ordered.
Ensures serializability through timestamp-based ordering.
Disadvantages:
May lead to starvation of newer transactions due to frequent aborts.
Requires additional storage for maintaining timestamps.
Advantages
No Log Files: Eliminates the overhead of maintaining log files.
Fast Recovery: Crash recovery is quick since only page tables are swapped.
Isolation: Transactions operate on separate copies, reducing interference.
Disadvantages
Commit Overhead: Flushing all modified pages during commit increases overhead.
Data Fragmentation: Pages may become scattered, leading to fragmentation.
Garbage Collection: Old versions of modified pages require clean up after transactions.
16] What is Serializable schedule? Explain with suitable example the types
of serializable schedules.
Serializable Schedule
A serializable schedule is a sequence of operations from multiple transactions that can be
executed concurrently while maintaining the same outcome as if they were executed
sequentially. This ensures that the final state of the database is consistent and adheres to all
integrity constraints, even when transactions overlap in their execution.
Conflict Serializable Schedule:
A schedule is conflict serializable if it can be transformed into a serial schedule by swapping
non-conflicting operations.
Example: Consider two transactions T1 and T2 accessing different data items A and B. If T1
reads A and writes A, and T2 reads B and writes B, this schedule is conflict serializable
because it can be rearranged into a serial order (e.g., T1 then T2).
View Serializable Schedule: A schedule is view serializable if it is view equivalent to a
serial schedule, meaning the final state of the database is the same as if transactions were
executed sequentially.
Example: Suppose T1 reads A, writes A, and T2 reads A, writes A. If the final value of A is
the same as if T1 executed before T2 or vice versa, the schedule is view serializable.
Example of Serializable Schedule
Consider two transactions T1 and T2:
T1 T2
R(A) R(B)
W(A) W(B)
R(C) R(C)
W(C) W(C)
This schedule is serializable because it can be rearranged into a serial order (e.g., T1 followed
by T2) without changing the final database state.
Non-Serializable Schedule Example
If T1 reads A, writes A, and T2 reads A before T1 writes A, the schedule is not serializable
because T2 reads uncommitted data (a dirty read), which cannot be transformed into a valid
serial order.
T1 T2
R(A) R(A)
W(A) W(A)