dbms 5
dbms 5
Long 5 marks
Ans. It is a set of operation. It can be read and write of operation. It is
single logical unit of work. After every transaction it execute commit
statemet.
Property of Transaction
1. Atomicity
2. Consistency
3. Isolation
4. Durability
Atomicity
o It states that all operations of the transaction take place at once if
not, the transaction is aborted.
o There is no midway, i.e., the transaction cannot occur partially. Each
transaction is treated as one unit and either run to completion or is
not executed at all.
Abort: If a transaction aborts then all the changes made are not visible.
Commit: If a transaction commits then all the changes made are visible.
T1 T2
Read(A) Read(B)
A:=A-100 Y:=Y+100
Write(A) Write(B)
Consistency
o The integrity constraints are maintained so that the database is
consistent before and after the transaction.
o The execution of a transaction will leave a database in either its
prior stable state or a new stable state.
o The consistent property of database states that every transaction
sees a consistent database instance.
o The transaction is used to transform the database from one
consistent state to another consistent state.
For example: The total amount must be maintained before or after the
transaction.
Isolation
o It shows that the data which is used at the time of execution of a
transaction cannot be used by the second transaction until the first
one is completed.
o In isolation, if the transaction T1 is being executed and using the
data item X, then that data item can't be accessed by any other
transaction T2 until the transaction T1 ends.
o The concurrency control subsystem of the DBMS enforced the
isolation property.
Example :
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
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.
1. Data Consistency: ACID properties ensure that the data remains consistent
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.
4. Recovery: ACID properties ensure that in case of any failure or crash, the
integrity.
In a database transaction, the two main operations are READ and WRITE operations.
So, there is a need to manage these two operations in the concurrent execution of
the transactions as if these operations are not performed in an interleaved manner,
and the data may become inconsistent. So, the following problems occur with the
Concurrent Execution of the operations:
For example:
Consider the below diagram where two transactions T X and TY, are
performed on the same account A where the balance of account A
is $300.
o At time t1, transaction TX reads the value of account A, i.e., $300 (only
read).
o At time t2, transaction T X deducts $50 from account A that becomes $250
(only deducted and not updated/write).
o Alternately, at time t3, transaction T Y reads the value of account A that will
be $300 only because TX didn't update the value yet.
o At time t4, transaction TY adds $100 to account A that becomes $400 (only
added but not updated/write).
o At time t6, transaction TX writes the value of account A that will be
updated as $250 only, as TY didn't update the value yet.
o Similarly, at time t7, transaction T Y writes the values of account A, so it will
write as done at time t4 that will be $400. It means the value written by
TX is lost, i.e., $250 is lost.
For example:
For example:
o At time t1, transaction TX reads the value from account A, i.e., $300.
o At time t2, transaction TY reads the value from account A, i.e., $300.
o At time t3, transaction T Y updates the value of account A by adding $100
to the available balance, and then it becomes $400.
o At time t4, transaction TY writes the updated value, i.e., $400.
o After that, at time t5, transaction T X reads the available value of account
A, and that will be read as $400.
o It means that within the same transaction T X, it reads two different values
of account A, i.e., $ 300 initially, and after updation made by transaction
TY, it reads $400. It is an unrepeatable read and is therefore known as the
Unrepeatable read problem.
For example:
Explanation:
Next Page
Explanation:
Serial Schedule leads to less resource Serializable Schedules improves both less
utilization and cpu throughput. resource utilization and cpu throughput.
Serial Schedule are less efficient as Serializable schedules are always better than
compared to serializable schedules. serial schedule