Unit4 Dbms
Unit4 Dbms
2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health and safety, and the cultural, societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to
provide valid conclusions.
Contd..
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering solutions
in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms
of the engineering practice.
Contd..
9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams,
and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and design
documentation, make effective presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one’s own work, as a member and leader in a team, to manage
projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent
and life-long learning in the broadest context of technological change.
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
ACSAI0402.1
2 2 3 3 3 2 3 2 2 2 2 3
ACSAI0402.2
3 3 3 2 2 2 2 2 2 2 2 3
ACSAI0402.3
2 3 3 3 3 2 2 2 2 2 2 2
ACSAI0402.4
2 3 2 2 2 2 2 2 2 3 2 2
ACSAI0402.5
2 3 2 2 2 3 2 2 3 2 2 2
AVG
2.20 2.80 2.60 2.40 2.40 2.20 2.20 2.00 2.20 2.20 2.00 2.40
ACSAI0402.1
3 1 3 1
ACSAI0402.2
3 1 3 1
ACSAI0402.3
3 1 3 1
ACSAI0402.4
3 1 3 1
ACSAI0402.5
3 1 3 1
AVG
3.00 1.00 3.00 1.00
SECTION – B CO
Unit-4
05/15/2024 17
Brief Introduction about the Subject
Topic CO
Transaction system CO4
Topic CO
Recovery with concurrent transaction, Case study of Oracle CO1
Distributed Database: -Introduction Distributed Database CO1
Centralized and Distributed System Database System. CO1
Challenges:-
Concurrency Control: How do the DBMSs handle
concurrent transactions?
Crash Recovery: How do the DBMSs handle partial
transactions because of machine crashes or users abort the
transactions ?
3. If both the transactions are for write operation, then they are
in conflict but can be allowed to take place in any order,
because the transaction do not read the value updated by
each other. However, the value that persists in the data item
after the schedule is over is the one written by the instruction
that performed the last write.
Finally we can say:-
Two instruction/operation are said to be in conflict Operation,
if they satisfy all the following three conditions:-
1. Two operation are set of conflicting when they should
belong to different transactions.
2. Both the instruction are working on same data item.
3. At least one of the instruction is a write instruction.
05/15/2024 Sana Anjum ACSAI-0402 and DBMS Unit-4 57
Conflict Equivalent Schedules
2. precedence Graph.
2. Update Read
• In S1, transaction T2 reads the value of X, written by T1. In S2, the same
transaction T2 reads the X after it is written by T1.
• In S1, transaction T2 reads the value of Y, written by T1. In S2, the same
transaction T2 reads the value of Y after it is updated by T1.
• The update read condition is also satisfied for both the schedules.
3. Final Write
• In schedule S1, the final write operation on X is done by transaction T2. In
S2 also transaction T2 performs the final write on X.
• Lets check for Y. In schedule S1, the final write operation on Y is done by
transaction T2. In schedule S2, final write on Y is done by T2.
• We checked for both data items X & Y and the final write condition is
satisfied in S1 & S2.
Result:-
Since all the three conditions that checks whether the two schedules are
view equivalent are satisfied in this example, which means S1 and S2 are
view equivalent.
Also, as we know that the schedule S2 is the serial schedule of S1, thus we
can say that the schedule S1 is view serializable schedule.
Note:-
1. All conflict serializable schedules are view serializable.
2. All view serializable schedules may or may not be conflict serializable.
Method-02:
Check if there exists any blind write operation. (Writing without reading is
called as a blind write).
If there does not exist any blind write, then the schedule is surely not view
serializable. Stop and report your answer.
If there exists any blind write, then the schedule may or may not be view
serializable. Go and check using other methods.
Note:-
No blind write means not a view serializable schedule.
Method-03:
In this method, try finding a view equivalent serial schedule.
Basic :-
• The order of execution of the transaction is called a schedule,
may it be a serial schedule or a concurrent schedule.
Now due to this concurrency in schedules there can arise a lot of issues
such as inconsistent schedule.
Let us understand this with a simple example: Let’s say you are coping an
examination paper from the person sitting in front of you. Then you
should not submit/commit your paper until and unless the person in front
of you submits first. Because he may later add some more points or
change some answers which you will missout.
Example
Cascading Schedule-
• If in a schedule, failure of one transaction causes several other dependent
transactions to rollback or abort, then such a schedule is called as
a Cascading Schedule or Cascading Rollback or Cascading Abort.
• It simply leads to the wastage of CPU time.
Example-
In other words,
• Cascadeless schedule allows only committed read operations.
• Therefore, it avoids cascading roll back and thus saves CPU time.
Example
Here no uncommitted reads are allowed. That is no dirty reads are
allowed. That is no W-R problem. Disallowing a transaction from reading
uncommitted changes from another transaction. Cascadeless schedules
are also recoverable.
NOTE-
• Cascadeless schedule allows only committed read operations.
• However, it allows uncommitted write operations.
Example-
In the above figure, this schedule is strict because T2 is doing R(X) only
after committing T1. R(Y) is before commit but that is okay because it is on
different data.
Remember-
• Strict schedules are more strict than cascadeless schedules.
• All strict schedules are cascadeless schedules.
• All cascadeless schedules are not strict schedules.
Example :-
Consider transaction Ti that transfers $50 from account A to account B
– Two updates: subtract 50 from A and add 50 to B
Transaction Ti requires updates to A and B to be output to the database.
– A failure may occur after one of these modifications have been made
but before both of them are made.
– Modifying the database without ensuring that the transaction will
commit may leave the database in an inconsistent state.
– Not modifying the database may result in lost updates if failure occurs
just after transaction commits.
05/15/2024 Sana Anjum ACSAI-0402 and DBMS Unit-4 94
Data Access
Physical blocks are those blocks residing on the disk.
Buffer blocks are the blocks residing temporarily in main
memory.
Block movements between disk and main memory are
initiated through the following two operations:
– input(B) transfers the physical block B to main memory.
– output(B) transfers the buffer block B to the disk, and
replaces the appropriate physical block there.
We assume, for simplicity, that each data item fits in, and is
stored inside, a single block.
shadow-copy
1. Log-Based Recovery
2. Shadow Paging
The checkpoint is used to declare a point before which the DBMS was in
the consistent state, and all transactions were committed.
In the following manner, a recovery system recovers the database from this
failure:-
Example :-
Eventually, the transaction log file may not be handled as the size
keeps growing. This can be addressed with checkpoints.
• It is shown that the precedence graph has a pair G = (V, E), where
V and E are the ___, respectively.
1. Edges
2. Vertices
3. Edges and Vertices
4. Vertices and Edges
Deadlock Prevention:- This protocol ensure that the system is not goes
deadlock state
There are two approaches to deadlock prevention.
1. One approach ensures that no cyclic waits can occur by ordering the requests
for locks.
1.Wait-Die Scheme
2.Wound-Wait Scheme
Wait-Die scheme
• In this scheme, if a transaction requests for a resource which is already held
with a conflicting lock by another transaction then the DBMS simply checks
the timestamp of both transactions. It allows the older transaction to wait
until the resource is available for execution.
• Let's assume there are two transactions Ti and Tj and let TS(T) is a timestamp
of any transaction T. If T2 holds a lock by some other transaction and T1 is
requesting for resources held by T2 then the following actions are performed
by DBMS:-
• Check if TS(Ti) < TS(Tj) - If Ti is the older transaction and Tj has held some
resource, then Ti is allowed to wait until the data-item is available for
execution. That means if the older transaction is waiting for a resource which
is locked by the younger transaction, then the older transaction is allowed to
wait for resource until it is available.
05/15/2024 Sana Anjum ACSAI-0402 and DBMS Unit-4 119
Preemption-Prevention to Deadlock
A. Idle
B. Waiting
C. Deadlock
D. Ready
The deadlock state can be changed back to stable state by using _____________
statement.
A. Commit
B. Rollback
C. Savepoint
D. Deadlock
• Concurrency Control
it is process of managing simultaneous execution of
transaction in a shared database to ensure the serializability of
transaction.
Conservative 2-PL –
• Static 2-PL, this protocol requires the transaction to
lock all the items it access before the Transaction
begins execution by pre-declaring its read-set and
write-set.
If any of the predeclared items needed cannot be locked, the
transaction does not lock any of the items, instead it waits until
all the items are available for locking.
Conflict serializable, view serializable.
Possibility of irrecoverable schedules, cascading rollbacks
Strict-2PL
The first phase of Strict-2PL is same as 2PL.
After acquiring all the locks in the first phase, the
transaction continues to execute normally. But in contrast
to 2PL, Strict-2PL does not release a lock after using
it(write operation).
Partial shrinking Phase.
Strict-2PL holds all the locks until the commit point and
releases all the locks at a time.
Strict-2PL does not have cascading abort as 2PL does.
• Following Strict 2-PL ensures that our schedule is:
– Recoverable
– Cascadeless
Sana Anjum ACSAI-0402 and DBMS
05/15/2024 147
Unit-4
The Two-Phase Locking Protocol (Cont.)
Rigorous 2-PL –
It is an improvement over 2PL protocol.
This requires that in addition to the lock being 2-
Phase all Exclusive(X) and Shared(S) Locks held by the
transaction be released until after the Transaction
Commits.
No shrinking phase is there in the life of transaction.
Following Rigorous 2-PL ensures that our schedule is:
– Recoverable
– Cascadeless
– Serializability
Sana Anjum ACSAI-0402 and DBMS
05/15/2024 148
Unit-4
Graph Based Protocol
• A lock based technique that guarantees serializability that is
not based on 2PL.
• Additional information is required, how the transactions will
use the data.
• We need an idea about the order the data items are to be
accessed.
• Partial ordering is imposed on the data items.
• Only Exclusive Locks are allowed.
• The first lock by Ti may be on any data item.
• Subsequently, a data Q can be locked by Ti only if the
parent of Q is currently locked by Ti.
• Data items can be unlocked at any time.
• Data item locked and unlocked by a transaction Ti can not
be subsequently relocked by the same transaction.
Read Phase:
Values of committed data items from the database can be read
by a transaction. Updates are only applied to local data
versions.
Validation Phase:
Checking is performed to make sure that there is no violation of
serializability when the transaction updates are applied to the
database.
Write Phase:
On the success of the validation phase, the transaction updates
are applied to the database, otherwise, the updates are
discarded and the transaction is slowed down.
05/15/2024 Sana Anjum ACSAI-0402 and DBMS Unit-4 152
Multiple Granularity Locking Scheme
• Transaction Ti can lock a node Q, using the following rules:
1. The lock compatibility matrix must be observed.
2. The root of the tree must be locked first, and may be
locked in any mode.
3. A node Q can be locked by Ti in S or IS mode only if the
parent of Q is currently locked by Ti in either IX or IS mode.
4. A node Q can be locked by Ti in X, SIX, or IX mode only if
the parent of Q is currently locked by Ti in either IX or SIX
mode.
5. Ti can lock a node only if it has not previously unlocked any
node (that is, Ti is two-phase).
6. Ti can unlock a node Q only if none of the children of Q are
currently locked by Ti.
• Observe that locks are acquired in root-to-leaf order, whereas
they are released in leaf-to-root order.
05/15/2024 Sana Anjum ACSAI-0402 and DBMS Unit-4 153
Multiple Granularity (CO4)
• Allow data items to be of various sizes and define a hierarchy of
data granularities, where the small granularities are nested within
larger ones.
• Can be represented graphically as a tree.
• When a transaction locks a node in the tree explicitly, it implicitly
locks all the node's descendents in the same mode.
• Granularity of locking (level in tree where locking is done):
– fine granularity (lower in tree): high concurrency, high locking
overhead
– coarse granularity (higher in tree): low locking overhead, low
concurrency
Reference Book :- DATABASE SYSTEM Concepts (6th Edition) Abraham
Silberschatz, Henry F. Korth, S. Sudarshan. Page No. -679-682.
For video link:-
http://www.infocobuild.com/education/audio-video-courses/computer-scienc
e/FundamentalsOfDatabaseSystems-IIT-Kanpur/lecture-42.html
https://www.youtube.com/watch?v=jm1NUBMpyVo
Less danger of a single-point failure. When one of the computers fails, the
workload is picked up by other workstations.
Data are also distributed at multiple sites.
The end user is able to access any available copy of the data, and an end
user's request is processed by any processor at the data location.
Improved communications. Because local sites are smaller and located
closer to customers.
Reduced operating costs. It is more cost effective to add workstations to a
network than to update a mainframe system.
Faster data access, faster data processing.
A distributed database system spreads out the systems workload by
processing data at several sites.
• What is serializability?
• What are the types of serializable schedules?
• Define recoverability.
• What do you understand by log based recovery?
• Explain concurrency control.
• What do you mean by directory system.
• What is distributed data storage?
• How do you test serializability?
• In which state, the transaction will wait for the final statement has
been executed?
a) Active
b) Failed
c) Aborted
d) partially committed
• A Transaction ends
a) only when it is Committed.
b) only when it is Rolled-back
c) when it is Committed or Rolled-back
d) only when it is initialized
2. Attempt all the parts. Pick the correct option from glossary. [CO1]
i) Consistency ii)Isolation iii) Durability iv)Timestamp v)tuple
a) The __________ data type stores date as well as time
b) _____________ ensures that the database properly changes states upon a successfully
committed transaction.
c) ________ enables transactions to operate independently of and transparent to each
other.
d) _________ ensures that the result or effect of a committed transaction persists in case
of a system failure.
e) Record is also called as a _______
• http://www.aktuonline.com/papers/btech-cs-5-sem-data-base-man
agement-system-KCS501-2020.pdf
• http://www.aktuonline.com/papers/btech-cs-5-sem-database-man
agement-system-KCS-501-2018-19.pdf
• http://www.aktuonline.com/papers/btech-cs-5-sem-database-man
agement-system-ncs-502-2017-18.pdf
• http://www.aktuonline.com/papers/btech-cs-5-sem-database-man
agement-system-ncs-502-2016-17.pdf
05/15/2024 198
Sana Anjum ACSAI-0402 and DBMS Unit-4
University Question Papers