Vous êtes sur la page 1sur 16

GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR

OR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY


DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

1 11 1

TRANSACTION PROCESSING:
- It is small unit of database processing, which consist set of
operation to perform on the data item.
- Every transaction consist two operation ,Read and Write
- Read(x): it read the value of data item x from the database to
the buffer associated with transaction.
- Write(x): it write the value of data item x from the buffer
associated with the transaction to the database.
- Note: x is the data item, Buffer: is the temporary memory
location.
- Example transaction are
- A) Booking of air ticket
- B) Transaction of money from one a/c to another a/c.
- A transaction include one or more database operations
i) Insertion.
ii) Deletion
iii) Modification
iv) Retrieve
- If a database operation in a transaction do not update the
database but only retrieve data, the transaction is called as
read only operation.
- Read-item(x):
i) Find the address of disk block that contain x.
ii) Copy that disk into buffer in main memory( if the disk
block is not already in memory)
- Copy item(x) from buffer to the program variable name(x).

- Write-item(x):
I) Find the address of disk block that contain x.
II) Copy the disk block into buffer in main memory.
III) Copy x item from program variable need x into correct
location in the buffer.
IV) Store the updated block from the buffer back to disk.
GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

2 22 2


Note: the d.b.m.s will generally maintain number of buffer in
main memory that hold database disk block contain database
items being processed.
- When buffer is full, some replacement policy are used to
replace the current buffer, this replacement policy is called
page replacement.

- Example: write transaction for transfer Rs.1000 from a/c A to
a/c B.
T1: Read (A)
A=A-1000
Write (A)
Read (B)
B=B+1000
Write (B)
Transaction Initialization
In the transaction most important active agent is user, who
will responsible for all initialization process. During the
process a transaction has covered some predefined stages.

Commit

Db modified
No Error
System Error
Begin
1ransacLlon
Error Abort unmodified
Act|ve User
art|a||y
Comm|tted
Comm|tted
Ia||ed Aborted
1erm|nated
GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

3 33 3

A transaction that complete it executation successfully is said


to be commmited.
- Once the transaction is commied we cannot undo its effect by
aborting it.
- The only way to undo is to execute a compensating
transaction.
- Active:it is the intial stage of transaction. A transaction goes
in active state after it start executing.
- Partially Commited; When all the operation of the
transaction has been completed with no error, it goes partially
committed state. At this stage some update may still reside in
buffer.
- Commite: At this point all the updated made by transaction
has been properly reflected on the disk from the buffer. Once
the transaction is committed, the changes will persist even if
system is failure.
- Failed: if the normal execution of transaction could not
proceed the transaction goes to failed state.
- Aborted: once the transaction is fail to complete exection all
the changes made by the transaction on D.B must be undone.
At this point transaction goes into abort stage.
- Terminated: Once the transaction leaves the system, it is said
to be terminated. A transaction may be terminated if it has
either committed or aborted.



GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

4 44 4

Properties of Transaction
To maintain dataintegrity and consistency when concurrent
takes place.each transaction satisfy the ACID property.
ACID

ATOMICITY CONSISTENCY ISOLATION DURABILITY

Atomicity: this property basically shows the behaviour of
transaction inter of unique.
-Atomicity means all the operation of the transaction are reflected
properly in the database or none of the operation are reflected.
- it has to rechecked to termination stage,either followed by commit
stage or followed by abort stage.
- the basic behind the atomicity is the database system keeps
tracks of old value of any data on which transaction perform write
and if the transaction doesnot complete its exection, the old value
are restored to make it appear as though the transaction never
executed.
Consistency: This property will basically shows the behaviour of
transaction in term of consistency, i.e if the transaction is
successful that what ever the changes made by the user should be
refleted on the database.
- If the transaction is failed/unsucccessfull then the database
shows the prexiting thing but discarding the current
transaction.
GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

5 55 5

Isolation: it indicates that unique in nature of an transaction i.e if


a transaction is carried out (under execution) then the other
transaction should not start in between execution,until and unles
ist one is terminted.
Ex: there are two transaction T1 & T2. It appear to T1 that either T1
finished execution before T1 or T2 started execution after T1
finished.
- The isolation property is the responsible of a components of
the database system called Concurrency controlled
components.
Durability: once the execution of the transaction complete
successful all the updates that is carriedout on the datbase persist
even if there is asystem failure after the transaction is complete
execution. It is responsible for recovery management.
Note: database must consistent for a long period. It should not
hampered lossees of data due to any circumstances.
Concurrency Control
Concurrency control is the mechanisam of transaction processing
system that allow multiple transaction to run at a time inefficent
maner so that database should not be inconsistent.
As we know that there are numoruous of queries in DBMS
insert,delete,update etc, hence the most complexity will get arised
then the DB is updated hence the concurrency control is the
mechanisam using which we can carryout simoultneously without
any repeation.
GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

6 66 6

Problems/Disadvantages:
As we know that when two transaction attempts to odify/update the
same time,and on some data item.some time it may suffer the
following problems susch as.
1) Lost update problem
2) Dirty read problem
3) Unpredictable read
Lost Update Problem:
This problem occurs when two transaction attempts to mainly
update/modify at same time on same data. Then the update made
by one transaction T1 on data item x is lost due to the update
made by another transaction T2 on data item x.
Ex: let us consider two transaction T1 & T2
T1 T2
Read(A) Read(A)
A=A+5000 A=A+10000
Write(A) Write(A)
Let us consider the schedualr transaction T1 & T2 at same
time,intially value of A=3000, what is the value after transaction T2.
Ans: T1: Read (A) A=A+5000=3000+5000=8000
Wrie(A)
T2: Read(A) A=A+10000 now the value of A is 8000, then
GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

7 77 7

A=a=A+10000
A=8000+10000
18000
After the transaction T2 value 18000
Due to loss update problem:
Read(A)----- T1 (A=3000)
A=A+5000 A=3000+5000=8000
Write(A)
Read(A)------T2
A=A+10000 (A=13000)
Write(A)
The above schedule the actual value of A is 18000, but it comes to
13000 because transaction T2 Read(A) before the update of T1 is
stored in the database.
Dirty Read Problem:
This problem occurs when one transaction T1 update dataitem X
and then transaction fails, the value of X will be rollback to original
value.but it means that another transaction T2 has the read the
value of X before it can Rollback . The value of X read by T2 is dirty
read of data. Since it is the value created by the transaction that
has been aborted this problem is known as Dirty read problem.

GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

8 88 8

Unpredictable Problem:
When more than one transactiobn are occuring cocurrently in the
same database and try to manipulate the same attribute of
database, in due course of time let 1
st
transaction makes some
changes then after,next transaction make the same changes again
and again,by default non of them can reflect on the database.then
the database hold with previous value.
Or if the transaction makes same changes and before commiting it
the other transaction applies a rollback command the database
cannot be consistent.
Solution for the problem occur due to cocurrency:
To avoid the problem occur due to concurrency , uses the protocol.
1) Lock-Based Protocol
2) Timestamp protocol
3) Validation based protocol
4) Multiversion Protocol
Characterstics of cocurrency control:
1) Sharing of data maong users
2) Keep tight control on data redudancy
3) It represent the complex relation between different dataitem.
4) Has different interface through which user manipulate data.
5) Enforces data access authorization.


GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

9 99 9

Locking Mechanisam
it is a variable associated with adata item X that reflects the status
of data item X with respect to possible opeartion that can applied to
it.
- A data item X can be locked in two modes.
Or It is the basic mechanisam which is applied to the problem of
concurrent schedular that is ,it helps up to make the dat5abase
consistent.
Types of Lock:
1) Shared Lock (S-Lock)
2) Execlusive Lock (X-Lock)0
Shared Lock: if a transaction T1 has obtained a shared mode lock
then T1 can read but write.
- it is locking mechanisam which also refered as S-Lock
Mechanisam.
- This lock mechanisam basically perform the read mechanisam in
which if more than one one transaction tries to perform the s-lock
mechanisam than it is acceptable (No-Conflict arises).
Execlusive Lock: if a transaction has obtained an execlusive mode
lock then T1 can both read and write
-It is denoted by symbol X
- whenever a transaction T has to access a data item, it first request
for lock in appropiate mode on data item X. if the lock manager of
GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

10 10 10 10

DBMS grant the lock on X to transaction T, then only T can proceed


its operation on X.
T1: T2
Lock S(A) Lock X(A)
Read(A) Read(A)
Unlock(A) A=A-1000
Lock D(B) Write(A)
Read(B) Unlock(A)
Unlock(B) Lock X(B)
Display(A+B) Read(B)
B=B+1000
Unlock(B)
Grant Lock: When a transaction request a lock on a database in a
particular mode and no other transaction has lock on same
dataitem in a conflicting mode then the lock can be granted.
Binary Lock: it is locking process in which the possibility of
acquiring the lock over the attributes are either 0s and 1s.
- Here 0s represent shared lock which is used for Read Only
operation.
- 1s represent both read and write operations.

GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

11 11 11 11

Two-Phase locking Protocol: it is locking protocol ensure that the


serializability of multiple operation.
- This protocol states that each transaction in a schedule must
issue the lock and unlock request in two phases.
- 1) Growing Phase
- 2) Shrinking Phase
Growing Phase: in this phase a transaction request for lock the
data but cannot unlock any data item/may not realease lock.
Shrinking Phase: in this process a transaction can only release
lock on dataitem but cannot request for a lock.
- Intially a transaction is in the growing stage, at that time
transaction acquire lock on dataitem.
- Once the transaction release the lock it enter into shrinking
phase and it cannot acquire more lock request.
Example: T1:
Lock X(A)
Read(A)
A=A-1000
Write(A) Growing Phase
Lock X(B)
Read(B)
Write(A)
B=B+100
Unlock(A) Shrinking Phase
Unlock(B)

GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

12 12 12 12

T2:
Lock X(A)
Read(A)
Growing Phase
Lock X(B)
Read(B)
Display (A+B)
Unlock(A) Shrinking Phase
Unlock(B)

Time-Stamp Based Protocol:
- In such cases each transaction Ti in the system associated
with unique identifier.this unique identifier is called
timestamp of Ti denoted as Ts(Ti).
- If the transaction Tj enter the system after the transaction Ti
then Ts(Ti)<Ts(Tj). There are two simple method of
implementing this scheme.
- 1) use the value of the system clock as the timestamp
- 2) use a logical counter i.e incrment by one after a new
timestamp has been assigned.
- Ther are two time-stamp a) W-timestamp() b) R-timestamp()
- W-Timestamp()-it denotes largest timestamp of any
transaction that execute write() successfully.
- R-timestamp():- it denotes that the largest timestamp of any
transaction that executed Read() successfully.
- These timestamp are updated whenever a new read() or
write() instruction is executed.
GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

13 13 13 13

- When a transaction Ti is rejected and rollback by the system


as base on timestamp ordering protocol, then the system
assign anew timestamp and is restarted.
- The timestamp ensure that freedom from deadlock.
Deadlock: it is a situation where two transaction are in wait
state.
- There are two principle method for dealing with deadlock
problem.
Deadlock Prevention: protocol ensure that the system never
enter a deadlock state.
- When a system enter in the deadlock state try to recover using
a deadlock-detection and deadlock recovery.
- Two approaches a) no cyclic wait can occur by ordering the
request for locks.b) perform transaction rollback instead ofv
waiting for lock.
- In the first approaches each transaction locks all its data
items before it begin execution that means either all are locked
in one step or none are locked.
Deadlock Detection: if a system deadlock occur in the system
then the system must attempts to recover from deadlock and
system must do the following actions.
- A) maitain information about the current transaction of data
item to transaction as well as any outstanding datitem
request.
- B) provide an algorithm that uses this information to
determine whether the system has entered a deadlock state.
Deadlock Avoidance: a) select the victims-given a setof
deadlocked transaction, that must detremine which transaction
to be rolledback to break the deadlock.
GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

14 14 14 14

b) we should rollback those transaction that will be minimum


cost.
c) the minimumn cost of transaction can be determined by
following factor.
-i) how long the transaction hascomputed
ii) how many datitems the transaction needs to completee the
process.
iii) How many transaction will be involved in rollback.
Rollback: once we have decided that a particular transaction must
be rolledback,we must determine how far this transaction should be
rolledback.
Starvation: in a system where the selection of victim is based on
cost factor . it may happen that the same transaction is always
pickd as a victim.as a result the transaction never complete it
designated task. Such situation is called starvation.

Data Recovery System
A data recovery is the process which is used to recover the valuable
data of database then it is subjected to under failure.
Types of failure:
A database may undergoes failure state due to the following reason.
a) Transaction failure: there are two types of error causes of
transaction failure.
i) Logical error: the transaction cannot executed because
bad input data, data not found.
GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

15 15 15 15

ii) System failure: the system has entered undesirable state


such as deadlock,as a result the transaction cannot be
executed.
b) System Crash: there is H/W problems or error the database
softwares or error in operating system, that causes the loss of
content of volitile storage and transaction execution is halt.
c) Disk Failure: a diskblock losses its content a s result of either
head crash or failure a data transfer operation.
d) Storage Failure: it is one kind of natural failure where mainly
envirnoment is responsible.
Database Recovery:
It is a technique that restore the databasec to the most recent
consistent state that execited before failure.
a) Forward recovery (Reading)
b) Backward recovery (Undoing)
c) Media Recovery.
Recovery Techniques:
The most widely used scheme for the database recovery is log-
based recovery.
Log-based recovery: the structure used for recording the database
modification is called the log.
- The log is sequence of log records and maintain record of all
update activities in the dtabase.
- A log record has four field
- A) Transaction identifier: it is unique identifier of the
transacrtion that performed the write operation.
- B) Data item identifier: it is unique identifier of the dataitem
written.
GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY GANDHI INSTITUTE FOR EDUCTAION & TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE DEPARTMENT OF COMPUTER SCIENCE
PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH PREPARED BY Asst.Prof.SANTOSH KUMAR RATH
DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM
(FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE (FOR BOTH CSE- -- -4TH 4TH 4TH 4TH- -- -SEM/MECH SEM/MECH SEM/MECH SEM/MECH- -- -3RD SEM) 3RD SEM) 3RD SEM) 3RD SEM)
MODULE MODULE MODULE MODULE- -- -III III III III

16 16 16 16

- C) Old-value: it is value of data item prior to write


- D) New Value: t is value of that the data item will have after
the write.

Vous aimerez peut-être aussi