DBMS
DBMS
ACID PROPERTIES
TRANSACTION
Definition:
A transaction in database management is a single, logical unit of work that
consists of one or more database operations (such as insert, update, delete,
or retrieve) executed as a single sequence. A transaction is considered
complete only if all operations succeed; if any operation fails, the entire
transaction is rolled back, leaving the database in its original state.
plaintext
Copy code
Start Transaction
|
V
Execute Operations
|
Check for Errors (Any operation failed?)
|
+-------------+
| |
Yes | | No
V V
Rollback Commit
(Undo Changes) (Save Changes)
|
V
End Transaction
QUESTION&ANSWERS
1. The process of ensuring that data is accurate, consistent, complete, and valid throughout its
lifecycle
2. What is a sequence of one or more operations performed as a single, logical unit of work, and it
either completes fully or not at all
3.Ticket booking Is example of
4.what is used to save changes
5.what is used to revert changes
data integrity
transaction management
Isolation
Rollback
commit
PHASES OF TRANSACTION
PHASES
A) Active
B) Partially Committed
C) Committed
D) Terminated
TRANSACTION MANAGEMENT
TECHNIQUES
SCENARIO:
Users interact by liking,commenting or sharing post with changes.
TECHNIQUES USED:
Multiversion concurrency control(MVCC)
Deadlock management
Shadow paging or Write-Ahed logging(WAL)
BANKING SYSTEMS
SCENARIO:
When a user transfer money from one bank account to
another.
TECHNIQUES USED:
Atomicity
Isolation
Consistency
OTHER EXAMPLES
a.Ecommerce System
d.Telecommunication system
TYPES OF TECHNIQUES
The main purpose of the Two-Phase Commit Protocol (2PC) in distributed transactions is to:
A. Optimize query performance
B. Ensure consistency across multiple systems
C. Improve network speed
D. Minimize disk space usage
Answer: B. Ensure consistency across multiple systems
In the Two-Phase Locking (2PL) protocol, what are the two phases?
A. Read Phase and Write Phase
B. Locking Phase and Unlocking Phase
C. Prepare Phase and commit Phase
D. Request Phase and Release Phase
Answer: C. Prepare Phase and Commit Phase
ACID-Properties
ATOMICITY(A)
CONSISTENCY(C)
ISOLATION(I)
DURABILITY(D)
ATOMICITY
ATOMICTY
ATOMICTY
KEY POINTS
State Validation: Before a transaction, the database is in a valid state according to predefined
rules and constraints. After the transaction, the database must still be in a valid state. If a
transaction would violate these rules, it is aborted or rolled back.
Maintaining Business Logic: Consistency also means that business rules are consistently
followed. For instance, if a banking transaction ensures that money can’t be transferred if
funds are insufficient, this rule must always hold.
Error Prevention: Consistent transactions prevent incomplete or erroneous data from being
committed to the database. If a transaction is partially completed or fails, the DBMS should
roll back to the previous consistent state.
QUESTION &ANSWERS
Definition: Isolation ensures that transactions are executed independently of each other. Even if
multiple transactions are occurring concurrently, each transaction must execute as if it were the only
one. This prevents transactions from interfering with each other and causing data inconsistency.
Levels of Isolation: Database systems provide various isolation levels to balance performance and
consistency. The main isolation levels are:
Read Uncommitted: Allows a transaction to see uncommitted changes from other transactions. Fast
but can lead to dirty reads (inconsistent data).
Read Committed: A transaction can only read committed data, avoiding dirty reads but not non-
repeatable reads (where data read previously might change).
Repeatable Read: Prevents other transactions from modifying data read by a current transaction,
ensuring consistency but can still allow phantom reads.
Serializable: The highest level of isolation, ensuring transactions execute sequentially, but it can be
slower and may lead to more locks or deadlocks.
Isolation is critical for preventing problems like dirty reads, non-repeatable reads, and phantom reads.
DURABILITY