ASSIGNMENT-5
1. What is ACID property in a transaction. Explain each of the property with a
suitable example.
Sol:- ACID is an acronym that represents the four key properties(Atomicity, Consistency,
Isolation, and Durability) that guarantee reliable processing of database transactions. These
properties ensure that database transactions are processed in a consistent and dependable
manner.
a. Atomicity
Ensures that a transaction is treated as a single unit; either all its operations are
executed or none.
Example: In a fund transfer system, if you withdraw ₹1000 from Account A and deposit
into Account B, both operations must happen together. If any fails, the whole
transaction rolls back.
b. Consistency
Guarantees that a transaction brings the database from one valid state to another.
Example: If a rule says account balances must never be negative, transactions must not
violate that rule.
c. Isolation
Ensures that concurrent transactions do not interfere with each other.
Example: Two users booking the same seat should not be able to confirm it
simultaneously.
d. Durability
Ensures that once a transaction is committed, its changes are permanent—even if there
is a system crash.
Example: Once a bank transfer is confirmed, the new balances remain even if the server
restarts.
2. What does it mean by transaction state. Further depict/draw the transaction
states .
Sol:- A transaction state refers to the different phases a transaction goes through from its
inception to its completion or termination within a database management system.
Understanding these cstates is crucial for comprehending how the system manages and
controls transactions.
Transaction States:
1. Active – Transaction starts executing.
2. Partially Committed – All operations are executed, but not yet committed.
3. Committed – Changes are saved permanently.
4. Failed – An error occurred; transaction can’t proceed.
5. Aborted – All changes are rolled back.
3. Discuss about the concurrency and serializability in transaction .
Sol:- Concurrency control in database systems deals with managing the simultaneous
execution of multiple transactions. Allowing transactions to run concurrently can significantly
improve system throughput and resource utilization. Instead of processing transactions one
after another (serially), the system interleaves their operations.
Benefits of Concurrency:
Improved Throughput: More transactions can be processed in a given amount of time.
Reduced Waiting Time: Transactions might have to wait less for resources, leading to
faster response times.
Increased Resource Utilization: System resources (CPU, disk I/O) can be kept busy more
effectively.
Serializability is a property of transaction schedules that ensures that the effect of
executing multiple concurrent transactions is equivalent to executing them in some serial
order (one after the other). If a schedule is serializable, it guarantees that the database
remains consistent, as each individual transaction is assumed to maintain consistency.
4. Discuss in detail view serializable and conflict serializable in detail with suitable
examples. further explain how to identify given transaction are conflict and view
serializable.
Sol:- In database concurrency control, conflict serializability ensures that concurrent
transactions produce the same results as if they were executed serially, by swapping operations
that don't conflict (meaning they don't access the same data item with conflicting access
types). View serializability, on the other hand, guarantees the same view of the database as a
serial execution, but allows for more flexibility in scheduling, even if not conflict-serializable.
Conflict Serializability
A schedule is conflict serializable if it can be transformed into a serial schedule by swapping
non-conflicting operations.
Conflicts:
Two operations conflict if they belong to different transactions, access the same data item, and
at least one is a write operation.
Example:
Consider two transactions: T1: R1(A), W1(A), and T2: R2(A), W2(A). Here, R1(A) and W2(A)
conflict because they both read/write the same item (A) and at least one is a write. A schedule
where T1 precedes T2 (T1->T2) is not conflict-serializable because swapping R1(A) and W2(A)
would change the final result.
Identifying Conflict Serializability:
Use a precedence graph where nodes represent transactions, and an edge from T1 to T2 means
T1 precedes T2 in a conflict. If the graph has no cycles, the schedule is conflict-serializable.
View Serializability
A schedule is view serializable if the view of the database it produces is the same as the view
produced by some serial schedule.
View Equivalence:
Two schedules are view equivalent if they read the same values and write the same values to
the database.
Example:
Consider two transactions: T1: R1(A), R1(B), W1(A) and T2: R2(B), W2(B). A serial execution T1-
>T2 would make the view of A be the value written by T1, and the view of B be the value
written by T2. A concurrent execution can achieve the same view by ensuring T1 writes A
before T2 writes B, even if they access the same data item, and even if it is not conflict
serializable.
Identifying View Serializability:
Check if the initial values of data items read by each transaction are the same in both the
concurrent and serial schedules. Then, check if the final values written by each transaction are
the same in both schedules.
Relationship between Conflict and View Serializability
All conflict-serializable schedules are also view-serializable, but not the other way
around.
View serializability allows for more flexible scheduling, as it focuses on the final view of
the data rather than requiring complete order preservation like conflict serializability.
In summary: Conflict serializability ensures that concurrent transactions are effectively
executing serially by swapping non-conflicting operations. View serializability guarantees the
same view of the database, but allows for potentially more relaxed concurrency control, as it
focuses on the final result rather than specific ordering of operations.
6. Write the short notes on following: a) recoverable schedules b) cascading
schedules c) cascading rollback d) concurrency control.
Sol: -
a) Recoverable Schedules
A schedule is recoverable if a transaction T2 that reads a data item previously written by
another transaction T1 commits only after T1 commits. This ensures data consistency in the
event of failures.
Supporting Points:
1. Prevents dirty reads from being committed.
2. Ensures data integrity in multi-transaction systems.
3. Required for safe recovery in case of transaction failure.
4. Helps avoid cascading rollbacks when designed properly.
Example:
Let T1 and T2 be two transactions.
T1: Write(X)
T2: Read(X)
T1: Commit
T2: Commit
This is recoverable because T2 commits only after T1.
b) Cascading Schedules
A cascading schedule is one in which a transaction is allowed to read uncommitted changes
made by other transactions.
Supporting Points:
1. Can lead to data inconsistencies if the writer transaction aborts.
2. Causes cascading rollbacks when a failure occurs.
3. Not suitable for systems requiring high reliability.
4. Often avoided using strict or rigorous schedules.
Example:
T1: Write(X)
T2: Read(X) (before T1 commits)
If T1 fails, T2 must also roll back.
c) Cascading Rollback
Cascading rollback occurs when a single transaction failure causes other transactions, which
have read uncommitted data from it, to also roll back.
Supporting Points:
1. Increases the cost of failure recovery.
2. May affect multiple dependent transactions.
3. Leads to wasted computation and longer delays.
4. Avoided using strict schedules that prohibit reading uncommitted data.
Example:
T1: Write(X)
T2: Read(X)
T3: Read(X)
If T1 aborts, both T2 and T3 must also be rolled back.
d) Concurrency Control
Concurrency control is a set of techniques used in DBMS to manage simultaneous execution of
transactions without conflicting with each other, ensuring correctness and consistency.
Supporting Points:
1. Ensures isolation among concurrent transactions.
2. Prevents problems like lost updates, dirty reads, and inconsistent retrievals.
3. Techniques include locking, timestamp ordering, and multiversion concurrency control
(MVCC).
4. Aids in achieving serializability, the highest level of isolation.
Example:
Without control:
T1 and T2 both update the same account balance, leading to incorrect total.
With locking:
T1 locks the account, updates it, then unlocks. T2 waits, ensuring correct update.
SUBMITTED BY: -
NAME: - ARYAN RATH
REGD.NO: - 2301020069
GROUP: - 3
SLNO: -82