0% found this document useful (0 votes)
50 views4 pages

Transaction Assignment

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views4 pages

Transaction Assignment

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Define these terms:


atomicity, consistency, isolation, durability,
schedule, blind write, dirty read, unrepeatable read,
serializable schedule, recoverable schedule
thrashing, phantom problem
precedence graph, wait-for graph

2. What do you understand by


a. 2 phase locking
b. Optimistic concurrency control

3. Consider the following actions taken by transaction T 1 on database


objects X and Y : R(X), W(X), R(Y), W(Y)

1. Give an example of another transaction T 2 that, if run concurrently to transaction


T without some form of concurrency control, could interfere with T 1.

2. Explain how the use of Strict 2PL would prevent interference between the two
transactions.
3.Strict 2PL is used in many database systems. Give two reasons for its popularity.

4. Consider a database with objects X and Y and assume that there are
two transactions T1 and T 2. Transaction T 1 reads objects X and Y and then writes
object X. Transaction T 2 reads objects X and Y and then writes objects X and Y .

1. Give an example schedule with actions of transactions T1 and T 2 on objects X


and Y that results in a write-read conflict.
2. Give an example schedule with actions of transactions T1 and T 2 on objects X
and Y that results in a read-write conflict.
3. Give an example schedule with actions of transactions T1 and T 2 on objects X
and Y that results in a write-write conflict.
4. For each of the three schedules, show that Strict 2PL disallows the schedule.

5. We call a transaction that only reads database object a read-only transaction, otherwise the
transaction is called a read-write transaction. Give brief answers to the following questions:
1. What is lock thrashing and when does it occur?
2. What happens to the database system throughput if the number of read-write
transactions is increased?
3. What happens to the database system throughput if the number of read-only
transactions is increased?
4. Describe three ways of tuning your system to increase transaction throughput.

6. Answer the following questions: SQL supports four isolation-levels and


two access-modes, for a total of eight combinations of isolation-level and access-mode. Each
combination implicitly defines a class of transactions; the following questions refer to these
eight classes:
1. Consider the four SQL isolation levels. Describe which of the phenomena can
occur at each of these isolation levels: dirty read, unrepeatable read, phantom
problem.
2. For each of the four isolation levels, give examples of transactions that could be
run safely at that level.
3. Why does the access mode of a transaction matter?

7. Consider the university enrollment database schema:

Student(snum: integer, sname: string, major: string, level: string, age: integer)
Class(name: string, meets at: time, room: string, fid: integer)
Enrolled(snum: integer, cname: string)
Faculty(fid: integer, fname: string, deptid: integer)

The meaning of these relations is straightforward; for example, Enrolled has one record
per student-class pair such that the student is enrolled in the class.

For each of the following transactions, state the SQL isolation level you would use and
explain why you chose it.

1. Enroll a student identified by her snum into the class named ’Introduction to
Database Systems’.
2. Change enrollment for a student identified by her snum from one class to another
class.
3. Assign a new faculty member identified by his fid to the class with the least number of
students.
4. For each class, show the number of students enrolled in the class.

8. Consider the following schema:


Suppliers(sid: integer, sname: string, address: string)
Parts(pid: integer, pname: string, color: string)
Catalog(sid: integer, pid: integer, cost: real)

The Catalog relation lists the prices charged for parts by Suppliers. For each of the
following transactions, state the SQL isolation level that you would use and explain why
you chose it.

1. A transaction that adds a new part to a supplier’s catalog.


2. A transaction that increases the price that a supplier charges for a part.
3. A transaction that determines the total number of items for a given supplier.
4. A transaction that shows, for each part, the supplier that supplies the part at the
lowest price.
Concurrency Management

1. How does a lock manager handle Lock and Unlock.


2. How many types of access to database objects are available with lock protocol
implemented in database
3. What is lock downgrade and lock upgrade
4. How are the timestamps assigned to restarted transactions for
a. Deadlock prevention
b. Concurrency control

9. Consider the following classes of schedules: serializable, conflict-serializable, view-


serializable, recoverable, avoids-cascading-aborts, and strict. For each of the following
schedules, state which of the preceding classes it belongs to. If you cannot decide whether a
schedule belongs in a certain class based on the listed actions, explain briefly.

The actions are listed in the order they are scheduled and prefixed with the transaction
name. If a commit or abort is not shown, the schedule is incomplete; assume that abort or
commit must follow all the listed actions.

1. T1:R(X), T2:R(X), T1:W(X), T2:W(X)


2. T1:W(X), T2:R(Y), T1:R(Y), T2:R(X)
3. T1:R(X), T2:R(Y), T3:W(X), T2:R(X), T1:R(Y)
4. T1:R(X), T1:R(Y), T1:W(X), T2:R(Y), T3:W(Y), T1:W(X), T2:R(Y)
5. T1:R(X), T2:W(X), T1:W(X), T2:Abort, T1:Commit
6. T1:R(X), T2:W(X), T1:W(X), T2:Commit, T1:Commit
7. T1:W(X), T2:R(X), T1:W(X), T2:Abort, T1:Commit
8. T1:W(X), T2:R(X), T1:W(X), T2:Commit, T1:Commit
9. T1:W(X), T2:R(X), T1:W(X), T2:Commit, T1:Abort
10. T2: R(X), T3:W(X), T3:Commit, T1:W(Y), T1:Commit, T2:R(Y),
T2:W(Z), T2:Commit
11. T1:R(X), T2:W(X), T2:Commit, T1:W(X), T1:Commit, T3:R(X), T3:Commit
12. T1:R(X), T2:W(X), T1:W(X), T3:R(X), T1:Commit, T2:Commit, T3:Commit

10. Consider the following Concurrency Protocols. 2 PL, strict 2Pl, optimistic, timestamp. For
each of the schedules in the problem 9 above, which of the protocols allows the actions as
specified.
11. Consider the following sequences of actions listed in the order they are submitted to
database

Sequence S1: T1:R(X), T2:W(X), T2:W(Y), T3:W(Y), T1:W(Y),


T1:Commit, T2:Commit, T3:Commit
Sequence S2: T1:R(X), T2:W(Y), T2:W(X), T3:W(Y), T1:W(Y),
T1:Commit, T2:Commit, T3:Commit

For each sequence and for each of the following concurrency control mechanisms,
describe how the concurrency control mechanism handles the sequence.

Assume that the timestamp of transaction Ti is i. For lock-based concurrency control


mechanisms, add lock and unlock requests to the previous sequence of actions as per
the locking protocol. The DBMS processes actions in the order shown. If a transaction is
blocked, assume that all its actions are queued until it is resumed; the DBMS continues
with the next action (according to the listed sequence) of an unblocked transaction.
1. Strict 2PL with timestamps used for deadlock prevention.
2. Strict 2PL with deadlock detection. (Show the waits-for graph in case of deadlock.)
3. Conservative (and Strict, i.e., with locks held until end-of-transaction) 2PL.
4. Optimistic concurrency control.

You might also like