Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Mr.

Chatchai Suthapakti ID: 597-1303

Quiz#8 ITM 6505

This quiz covers the remaining of Topic 9 and Topic 10. They are
about scheduling and concurrency control of transactions. If you write
programs in multi users environment, these are the must know units.
These topics are not easy ones and are very interesting. Please do not
underestimate them and study them as soon as possible. You really need to
consult the Silberschatz, Korth and Sudarshan text book and the video
lectures, of course.

Give definitions and find the differences of the following schedules:

1. Serial schedules.
Answer:
It is a schedule in which transactions are aligned in such a way that one
transaction is executed first. When the first transaction completes its cycle, then the
next transaction is executed in a serial manner as following sample.
Let T1 transfer $50 from A to B, and T2 transfer 10% of the balance
from A to B.
- A serial schedule in which T1 is followed by T2 :
- A serial schedule where T2 is followed by T1

Anyway, the final result are the same.

2. Concurrent serializable schedules.


Answer:
In Concurrent Schedule, CPU time is being shared by different transactions by
following sample
3. Conflict serializable schedules.
Answer:
A schedule is called Conflict Serializable: if it can be transformed into a
serial schedule by swapping non-conflicting operations.
Sample of conflict serializable
- Schedule 3 is a conflict equivalent of schedule 6

Sample of not conflict serializable


- We are unable to swap sequence of operation.
4. View serializable schedules.
Answer:
View serializable schedule can be explain by verify with following sample
schedule 3 & 6 are view serializable schedule and conflict serializable

Firstly we have to check schedule 3 is view equivalent to a serial schedule then


verify by following 3 rules
1. - T1 read A first in schedule 3 and T1 also read A first in schedule 6
- T1 read B first in schedule 3 and T1 also read B first in schedule 6
2. - T2 read A and value of A written by T1 in schedule 3
- T2 read A and value of A written by T1 in schedule 6
- T2 read B and value of B written by T1 in schedule 3
- T2 read B and value of B written by T1 in schedule 6
3. – T2 write A last in schedule 3 and T2 also write A last in schedule 6
- T2 write B last in schedule 3 and T2 also write B last in schedule 6

The sequence that first & third conditions will consider to check first then the
second condition will follow to check as the last condition.

The sample of view serializable schedule with not conflict serializable


because of no transaction read from the other.
5. Recoverable schedules.
Answer:
Recoverable Schedules - Need to address the effect of transaction failures
on concurrently running transactions and all operations must be cancel or roll back.
The source transaction must commit first before the reader commit.

6. Cascadeless schedules.
Answer:
A Cascadeless schedule is one where, for each pair of transactions Ti and
Tj such that Tj reads a data item previously written by Ti , the commit operation of
Ti appears before the read operation of Tj.

Also, explain the following technical concepts:


7. The 4 concurrency control problems
Answer:
1. The lost update problem.
A lost update problem occurs when two transactions that access the
same database items have their operations in a way that makes the
value of some database item incorrect.
In other words, if transactions T1 and T2 both read a record and then
update it, the effects of the first update will be overwritten by the second
update as following sample transaction with time line.

2. The uncommitted dependency problem.


The phenomenon of uncommitted data occurs when two transactions
are executed concurrently and the transaction B is rolled back after the
second transaction A has already accessed the uncommitted data as
below sample so transaction A will fetch the wrong value
3. The inconsistent analysis problem.
Inconsistent analysis problem occur when a transaction accesses data
before and after another transaction(s) finish working with such data as
below sample

4. The phantom phenomenon.


The Phantom phenomenon arises when, due to an insertion or
deletion, two transaction logically conflict despite not locking any data
items in common. The insertion case and deletion can also lead to this
phenomenon. Suppose Ti insert a tuple into a relation while Tj scans the
relation so the result will appear incorrect by included the insertion
result.
8. Levels of Consistency in SQL
Be aware that you can set the default Levels of Consistency of your DBMS
and also set a particular level for each transaction so that it gives different
results (different schedules). Study how!
Answer:
Level of consistency will sort by best to worst
• Serializable – default
• Repeatable read - only committed records to be read, repeated reads of same
record must return same value. However, a transaction may not be serializable - it
may find some records inserted by a transaction but not find others.
• Read committed - only committed records can be read, but successive reads of
record may return different (but committed) values.
• Read uncommitted - even uncommitted records may be read.

You might also like