Complete schedule:
It is a schedule of transactions where each transaction is committed before terminating. The example is shown below where transactions T1 and T2 terminates after committing the transactions.
Example:
T1 T2
A=1000
Read(A)
A=A+100
Write(A) Read(A)
B=A-100
Write(B)
Commit
Read(B)
Write(B)
Serializability
• Serializability of schedules ensures that a non-serial
schedule is equivalent to a serial schedule. It helps in
maintaining the transactions to execute simultaneously without
interleaving one another.
Schedules in DBMS are of two types:
• Serial Schedule - A schedule in which only one transaction
is executed at a time, i.e., one transaction is executed
completely before starting another transaction.
Example
Transaction-1 Transaction-2
R(a)
W(a)
R(b)
W(b)
R(b)
W(b)
R(a)
W(a)
Non-serial Schedule -
• A schedule in which the transactions are interleaving or
interchanging. There are several transactions executing
simultaneously as they are being used in performing real-
world database operations. These transactions may be
working on the same piece of data. Hence, the serializability
of non-serial schedules is a major concern so that our
database is consistent before and after the execution of the
Example
Transaction-1 Transaction-2
R(a)
W(a)
R(b)
W(b)
R(b)
R(a)
W(b)
W(a)
Anomalies due to interleave execution of transaction:
Anomalies due to Interleaved execution • There are three main
situations when the actions of two transactions T1 and T2 conflict with
each other in the interleaved execution on the same data object.
Write-Read (WR) Conflict: Reading Uncommitted data.
Read-Write (RW) Conflict: Unrepeatable Reads
Write-Write (WW) Conflict: Overwriting Uncommitted Data
Reading uncommitted values(WR
conflicts):
1.If you try to the read the value which
is not written on to the data base(not
committed) will leads to write-read
conflict which is called dirty read
operation.
Un repeatable reading data operation(RW conflicts):
Reading the same object twice before committing the transaction might
yield an inconsistency
–Read-then-Write (RW) Conflicts (Write-After-Read)
Unrepeatable problem means we get different values in different
reads. For example in S1 say T2 read initially x=5 then T1 updated
x=1 so now T2 will read x=1 here T2 has read two different values
during consecutive reads This shouldn't have been allowed as T1 has
not committed
Overwriting uncommitted data(WW conflicts)
WW conflicts if one transaction could over write
the value of an object A
which has been already modified by other
transaction T1 while first transaction still in
progress .This kind of conflict refer to blind write
conflict.
Lock-Based Concurrency Control
• Locking is a concurrent control technique used to ensure
serializability. •
• There are two types of locks.
• A transaction needs to acquire a lock before performing a
transaction. •
• The read lock is known as shared lock and write lock is known as
exclusive lock. •
• A locking protocol is a set of rules that a transaction follows to attain
serializability
Strict Two-Phase Locking (Strict 2PL) Protocol
The Strict 2PL has the following two rules:
Rule 1: A transaction can read data only when it acquires a
shared lock and can write data only when it acquires an
exclusive lock on object.
Rule 2: A transaction should release the locks when it is
completed.
Concurrency Control Techniques are
1.Two-phase locking Protocol
2.Time stamp ordering Protocol
3.Multi version concurrency control
4.Validation concurrency control
Two Phase Locking
• Locking is an operation which secures: permission to read,
OR permission to write a data item. Two phase locking is a
process used to gain ownership of shared resources without
creating the possibility of deadlock. The 3 activities taking
place in the two phase update algorithm are:
(i) Lock Acquisition
(ii) Modification of Data
(iii) Release Lock
Cont..
• Two phase locking prevents deadlock from occurring in distributed
systems by releasing all the resources it has acquired, if it is not
possible to acquire all the resources required without waiting for
another process to finish using a lock. This means that no process is
ever in a state where it is holding some shared resources, and waiting
for another process to release a shared resource which it requires.
This means that deadlock cannot occur due to resource contention. A
transaction in the Two Phase Locking Protocol can assume one of the
2 phases:
Cont..
• Growing Phase: In this phase a transaction can only acquire
locks but cannot release any lock. The point when a
transaction acquires all the locks it needs is called the Lock
Point.
• Shrinking Phase: In this phase a transaction can only
release locks but cannot acquire any.
Time Stamp Ordering
• A timestamp is a tag that can be attached to any transaction or any
data item, which denotes a specific time on which the transaction
or the data item had been used in any way. A timestamp can be
implemented in 2 ways. One is to directly assign the current value
of the clock to the transaction or data item. The other is to attach
the value of a logical counter that keeps increment as new
timestamps are required. The timestamp of a data item can be of 2
types:
• (i) W-timestamp(X): This means the latest time when the data item
X has been written into.
• (ii) R-timestamp(X): This means the latest time when the data item
X has been read from. These 2 timestamps are updated each time
a successful read/write operation is performed on the data item X.
transaction management-database management system
transaction management-database management system
transaction management-database management system

transaction management-database management system

  • 7.
    Complete schedule: It isa schedule of transactions where each transaction is committed before terminating. The example is shown below where transactions T1 and T2 terminates after committing the transactions. Example: T1 T2 A=1000 Read(A) A=A+100 Write(A) Read(A) B=A-100 Write(B) Commit Read(B) Write(B)
  • 11.
    Serializability • Serializability ofschedules ensures that a non-serial schedule is equivalent to a serial schedule. It helps in maintaining the transactions to execute simultaneously without interleaving one another.
  • 12.
    Schedules in DBMSare of two types: • Serial Schedule - A schedule in which only one transaction is executed at a time, i.e., one transaction is executed completely before starting another transaction.
  • 13.
  • 14.
    Non-serial Schedule - •A schedule in which the transactions are interleaving or interchanging. There are several transactions executing simultaneously as they are being used in performing real- world database operations. These transactions may be working on the same piece of data. Hence, the serializability of non-serial schedules is a major concern so that our database is consistent before and after the execution of the
  • 15.
  • 16.
    Anomalies due tointerleave execution of transaction: Anomalies due to Interleaved execution • There are three main situations when the actions of two transactions T1 and T2 conflict with each other in the interleaved execution on the same data object. Write-Read (WR) Conflict: Reading Uncommitted data. Read-Write (RW) Conflict: Unrepeatable Reads Write-Write (WW) Conflict: Overwriting Uncommitted Data
  • 17.
    Reading uncommitted values(WR conflicts): 1.Ifyou try to the read the value which is not written on to the data base(not committed) will leads to write-read conflict which is called dirty read operation.
  • 18.
    Un repeatable readingdata operation(RW conflicts): Reading the same object twice before committing the transaction might yield an inconsistency –Read-then-Write (RW) Conflicts (Write-After-Read) Unrepeatable problem means we get different values in different reads. For example in S1 say T2 read initially x=5 then T1 updated x=1 so now T2 will read x=1 here T2 has read two different values during consecutive reads This shouldn't have been allowed as T1 has not committed
  • 19.
    Overwriting uncommitted data(WWconflicts) WW conflicts if one transaction could over write the value of an object A which has been already modified by other transaction T1 while first transaction still in progress .This kind of conflict refer to blind write conflict.
  • 20.
    Lock-Based Concurrency Control •Locking is a concurrent control technique used to ensure serializability. • • There are two types of locks. • A transaction needs to acquire a lock before performing a transaction. • • The read lock is known as shared lock and write lock is known as exclusive lock. • • A locking protocol is a set of rules that a transaction follows to attain serializability
  • 21.
    Strict Two-Phase Locking(Strict 2PL) Protocol The Strict 2PL has the following two rules: Rule 1: A transaction can read data only when it acquires a shared lock and can write data only when it acquires an exclusive lock on object. Rule 2: A transaction should release the locks when it is completed.
  • 23.
    Concurrency Control Techniquesare 1.Two-phase locking Protocol 2.Time stamp ordering Protocol 3.Multi version concurrency control 4.Validation concurrency control
  • 24.
    Two Phase Locking •Locking is an operation which secures: permission to read, OR permission to write a data item. Two phase locking is a process used to gain ownership of shared resources without creating the possibility of deadlock. The 3 activities taking place in the two phase update algorithm are: (i) Lock Acquisition (ii) Modification of Data (iii) Release Lock
  • 25.
    Cont.. • Two phaselocking prevents deadlock from occurring in distributed systems by releasing all the resources it has acquired, if it is not possible to acquire all the resources required without waiting for another process to finish using a lock. This means that no process is ever in a state where it is holding some shared resources, and waiting for another process to release a shared resource which it requires. This means that deadlock cannot occur due to resource contention. A transaction in the Two Phase Locking Protocol can assume one of the 2 phases:
  • 26.
    Cont.. • Growing Phase:In this phase a transaction can only acquire locks but cannot release any lock. The point when a transaction acquires all the locks it needs is called the Lock Point. • Shrinking Phase: In this phase a transaction can only release locks but cannot acquire any.
  • 27.
    Time Stamp Ordering •A timestamp is a tag that can be attached to any transaction or any data item, which denotes a specific time on which the transaction or the data item had been used in any way. A timestamp can be implemented in 2 ways. One is to directly assign the current value of the clock to the transaction or data item. The other is to attach the value of a logical counter that keeps increment as new timestamps are required. The timestamp of a data item can be of 2 types: • (i) W-timestamp(X): This means the latest time when the data item X has been written into. • (ii) R-timestamp(X): This means the latest time when the data item X has been read from. These 2 timestamps are updated each time a successful read/write operation is performed on the data item X.

Editor's Notes

  • #5 - This is the first state of transaction and here the transaction is being executed. For example, updating or inserting or deleting a record is done here. But it is still not saved to the database. When we say transaction it will have set of small steps, and those steps will be executed here.
  • #8 Schedule:  It refers to the list of actions to be executed by transaction.  A schedule is a process of grouping the transactions into one and executing them in a predefined order.  Schedule of actions can be classified into 2 types. 1. Serializable schedule/serial schedule. 2. Concurrent schedule. 1. Serial schedule: In the serial schedule the transactions are allowed to execute one after the other ensuring correctness of data. A schedule is called serial schedule, if the transactions in the schedule are defined to execute one after the other. 2. Concurrent schedule: Concurrent schedule allows the transaction to be executed in interleaved manner of execution
  • #9 A schedule is a list of actions(redaing,writing,aborting,committing) from a set of transactions the order in which two actions of transactions appear in a schedule must be the same.
  • #17 In above example, T1 write operation on data item A is not committed but it is being read by T2. So reading an uncommitted data will leads to inconsistency in database which is called dirty read operation.
  • #20 A lock is a small book keeping object associated with database object.
  • #26 Growing phase:-locks are acquired and no locks referred Shrinking phase:-locks are referred and no locks acquired