Csi ZG518 Ec-3r Second Sem 2021-2022
Csi ZG518 Ec-3r Second Sem 2021-2022
Csi ZG518 Ec-3r Second Sem 2021-2022
Comprehensive Examination
(EC-3 Regular)
Q.1 Set. (A) Consider there are transactions Ta and Tb each has two operations read and write on
data item A.
(a) Give an example of a schedule showing the lost update anomaly. (3 marks)
(b) Give an example schedule to show that the lost update anomaly is possible
with the read committed isolation level. (3 marks)
(c) Explain why the lost update anomaly is not possible with the repeatable read
isolation level. (4 marks)
Q.1 Set. (B) 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 above 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/commit must follow all the listed actions:
(a) T1:R(X), T1:R(Y), T1:W(X), T2:R(Y), T3:W(Y), T1:W(X), T2:R(Y)
(1mark)
(b) T1:R(X), T2:W(X), T1:W(X), T2:Abort, T1:Commit (1 mark)
(c) T1:W(X), T2:R(X), T1:W(X), T2:Abort, T1:Commit (1 mark)
(d) T1:W(X), T2:R(X), T1:W(X), T2:Commit, T1:Commit (1 mark)
(e) T1:W(X), T2:R(X), T1:W(X), T2:Commit, T1:Abort (1 mark)
(f) T2: R(X), T3:W(X), T3:Commit, T1:W(Y), T1:Commit, T2:R(Y), T2:W(Z),
T2:Commit (2 marks)
(g) T1:R(X), T2:W(X), T2:Commit, T1:W(X), T1:Commit, T3:R(X), T3:Commit
(1 mark)
(h) T1:R(X), T2:W(X), T1:W(X), T3:R(X), T1:Commit, T2:Commit, T3:Commit
(1 mark)
(i) T1:W(X), T2:R(Y), T1:R(Y), T2:R(X) (1 mark)
Q.1 Set. (C)
(a) Is the following view serializable?
(3 marks)
(b) Is the following view serializable?
S: r1(a) w2(a) w1(a)
T1T2: r1(a) w1(a) w2(a)
T2T1: w2(a)r1(a)w1(a) ) (3 marks)
(3 marks)
b) Assume that a transaction T1 would do a read and write on certain data items like
d1,d2,..,dk. Write down the pseudo code or algorithm for T1 as to how to acquire the
locks so that serializability and deadlock-freedom is achieved. (4 marks)
c) Write the wait for graph for the following and determine if deadlock or not?
(3 marks)
Total marks : 10 marks
ii) Lock_S(BASIC)
Lock_X(netsal)
Lock_S(deduct)
Lock_X(HRA)
R(BASIC)
R(deduct)
HRA= HRA + HRA *0.5
netsal = BASIC -deduct + HRA
Unlock(BASIC)
Unlock(deduct)
W(netsal)
W(HRA)
Commit
Unlock (netsal)
Unlock(HRA) ( 1 mark)
b) Consider the following code:
What would be the empno 15 ‘s and empno 17 ‘s wage be after Trans1 and Trans2
RUNS concurrently? (4 marks)
Total marks : 10 marks
Give an example of a query that would conflict with this command (in a concurrency
control sense) if both were run at the same time. Explain what could go wrong, and how
locking tuples would solve the problem?
(5 marks)
b. Consider the following sequences of actions, listed in the order they are submitted to the
DBMS:
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 above sequence of actions as per the
locking protocol. The DBMS processes actions in the order shown. If a transaction is
blocked, assume that all of 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.5 marks)
2. Strict 2PL with deadlock detection. (Show the waits-for graph if a deadlock cycle
develops.) (2.5 marks)
Total marks : 10 marks.
Q.3 Set. (A) Suppose that all the relations were created by (and hence are owned by) user X,
who wants to grant the following privileges to user accounts A, B, C, D, and E:
(a) Account A can retrieve or modify any relation except DEPENDENT and can
grant any of these privileges to other users. (1 mark)
(b) Account B can retrieve all the attributes of EMPLOYEE and DEPARTMENT
except for Salary, Mgr_ssn, and Mgr_start_date. (1 mark)
(c) Account C can retrieve or modify WORKS_ON but can only retrieve the
Fname, Minit, Lname, and Ssn attributes of EMPLOYEE and the Pname and
Pnumber attributes of PROJECT. (2 mark)
(d) Account D can retrieve any attribute of EMPLOYEE or DEPENDENT and can
modify DEPENDENT. (1 mark)
(e) Account E can retrieve any attribute of EMPLOYEE but only for EMPLOYEE
tuples that have Dno = 3. (1 mark)
(f) Write SQL statements to grant these privileges. Use views where appropriate.
(1 mark)
Q.3 Set. (B) Consider the following scenario in GG Corporations which has several members
using their DB.
(a) Where Salespersons, managers, and carpenters may read inventory records
but may not perform any other operations on these records.
(1 mark)
(b) Persons in Accounts Receivable and Accounts Payable may read and/or
update (insert, modify, delete) receivables records and customer records.
(1 mark)
(c) Inventory clerks may read and/or update (modify, delete) inventory records.
They may not view receivables records or payroll records. They may read
but not modify customer records.
(2 marks)
(d) How do we implement it using SQL stmts. (3 marks)
Q.3 Set. (C) Suppose that all the relations were created by UserX for ITTECH Corp’s
EMPLOYEE, DEPENDENT and PROJECT. UserX who wants to grant the
following privileges to user accounts Admin, Manager, ProjectManagers, Project
Leaders, Team Leader and Team members:
(a) Account Admin can retrieve or modify any relation except DEPENDENT and can grant
any of these privileges to other users. (1 mark)
(b) Account Manager can retrieve all the attributes of EMPLOYEE and DEPARTMENT
except for Salary, Mgr_ssn, and Mgr_start_date. (1 mark)
(c) Account Project Manager can retrieve or modify WORKS_ON but can only retrieve the
Fname, Minit, Lname, and Ssn attributes of EMPLOYEE and the Pname and Pnumber
attributes of PROJECT. (1 mark)
(d) Account Project Leader can retrieve any attribute of EMPLOYEE or DEPENDENT and
can modify DEPENDENT. (1 mark)
(e) Account Team Leader can retrieve any attribute of EMPLOYEE but only for
EMPLOYEE tuples who are in his team. (1 mark)
(f) Account Team member can retrieve any attribute of EMPLOYEE but only for
EMPLOYEE tuples who are in the same team. (1 mark)
(g) Write SQL statements to grant these privileges. Use views where appropriate. (1
mark)
For the following query, prepare the initial (canonical) query tree, then show how the query tree
is optimized by the use of heuristic optimization.
“For every project located in ‘Stanford’, list the project number, the controlling department
number, and the department manager’s lastname, address and birthdate. “
a. Draw the query tree. (5 marks)
b. Draw the heuristic optimization tree. (5 marks)
Q.4 Set. (B) Consider two relations Reserves and Sailors and statistical data are as follows:
Reserves:
– Each tuple is 40 bytes long, 100 tuples per page, 1000 pages.
– Let’s say there are 100 boats.
• Sailors:
– Each tuple is 50 bytes long, 80 tuples per page, 500 pages.
– Let’s say there are 10 different ratings.
No Indexes are available for both relations.
Compare the cost of two different query plans for the following query:
SELECT S.sname FROM Reserves R, Sailors S WHERE R.sid=S.sid AND R.bid=100 AND
S.rating>5
Total marks : 10 marks
Q.4 Set. (C) Consider two relations Employee and Department and statistical data are as
follows:
Employee:
– Each tuple is 40 bytes long, 100 tuples per page, 1000 pages.
– Let’s say there are 100 employees.
• Department:
– Each tuple is 50 bytes long, 80 tuples per page, 500 pages.
– Let’s say there are 10 different departments.
No Indexes are available for both relations.
Compare the cost of two different query plans for the following query:
Q.5 Set. (A) Consider an the application that needs to connect data about what the user is
looking for, what the user has bought in the past, what users like this user have
bought, what preferences and interests the user has, what products go well with
the product being viewed, what is currently in stock, and more.
Describe the schema required for the above system using NoSQL database.
Which NoSQL Database can be used? Total : 8 marks
Q.5 Set. (B) Consider an the application called weather service history. Weather history is all
statistical data on the state of the atmosphere and the ocean, collected on the basis
of regular meteorological observations made from hour to hour, day to day,
month to month, year to year — continuously.
The purpose of data collection is the same as any other statistical information: to
better understand the current weather situation and make better forecasts.
Describe the schema required for the above system using NoSQL database.
Which NoSQL Database can be used?
Total : 8 marks
Q.5 Set. (C) Consider an application that mainly deals with searching text-based documents
and how would this functionality be implemented.
Describe the schema required for the above application using NoSQL database.
Which NoSQL Database can be used? Total : 8 marks
*********