Csi ZG518 Ec-3m Second Sem 2021-2022

You might also like

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

Birla Institute of Technology & Science, Pilani

Work-Integrated Learning Programmes Division


Second Semester 2022-2022

Comprehensive Examination
(EC-3 Makeup)

Course No. : CSI ZG518


Course Title : Database Design and Applications
Nature of Exam : Open Book
Weightage : 45% No. of Pages = 8
Duration : 2 Hours No. of Questions = 5
Date of Exam : 29/05/2022 (AN)
Note:
1. Please follow all the Instructions to Candidates given on the cover page of the answer book.
2. All parts of a question should be answered consecutively. Each answer should start from a fresh page.
3. Assumptions made if any, should be stated clearly at the beginning of your answer.

Q.1 Set. (A)


Clearly specify the steps in the following questions:
a. Is the following conflict equivalent?
S1: w1(x) r2(z) w2(z) r2(x) r1(y)
S2: w1(x) r2(x) r2(z) w2(y) r1(z) (3 marks)

b. Is the following recoverable or strict or cascadeless schedule?


r1(x), w1(x), r2(x), r1(y) ,r2(y), w2(x), w1(y), a1,a2 (1 mark)
r1(x), w1(x) ,r1(y), w1(y), c1, r2(x), w2(x) ,c2 (1 mark)
r1(x), w1(x), r1(y), w1(y), r2(x), w2(x) ,c2 ,c1 (1 mark)

c. Consider the following schedules :


S1: r1(w), w1(x), r1(y) , w1(y), r1(x), w2(x), c2, c1
S2: r1(x), w1(x), r2(x), r1(y), w2(x), w1(y), c1, c2
Which schedule is recoverable? (4 marks)
Total marks : 10 marks.

Q.1 Set. (B)


a. Consider the following Schedule S having 4 transactions and are executed
Concurrently. The order of their operations are as follows:
S : r1(x), r2(y), w2(y), w3(x), r3(z), w3(y), r1(z), w4(x), w3(z), r4(x), r4(z), w4(z) c1, c2,
c3, c4
Find if S is what serializable? Conflict or view? Draw graph if needed. (4 marks)

b. Is the following recoverable or strict or cascadeless schedule?


r2(x), r1(x), w1(x), r1(y) ,w1(y), c1, w2(x), c2 (1 mark)
r1(x), r2(x) , w1(x), r1(y), w2(x), c2, w1(y) ,c1 (1 mark)
r1(x), w1(x), r2(x), r1(y), w2(x) ,c2 ,c1 (1 mark)
r1(x), w1(x), r2(x), r1(y), w2(x), c2, a1 (1 mark)
r1(x), w1(x), r2(x), r1(y), w2(x), w1(y), a1, a2 (1 mark)
r1(x), r2(x), w1(x), r1(y), w1(y), c1, w2(x), c2 (1 mark)
Total marks: 10 marks.

Q.1 Set. (C)


a. Is this view serializable or conflict serializable or both? Use Precedence graph.

( 3 marks)

b. Check if these two are view equivalent?

(3.5 marks)
c. Is this result equivalence?

(3.5 marks)
Total marks: 10 marks.
Q.2 Set. (A)
a. Consider the following code and Find out the what type of 2PL locking is used:
i) Lock_S(A)
Lock_X(B)
Lock_X( C)
R(A)
Unlock(A)
B= B-C+A
C = A -C
W(B)
Unlock(B)
W( C)
Unlock( C)
Commit (1.5 marks)

ii) Lock_S(A)
R(A)
Lock_X(B)
B= A+ 10
W(B)
Lock_X( C)
R( C)
C = B+ C
W( C)
Commit
Unlock(A)
Unlock(B)
Unlock( C) (1.5 marks)

b. Produce a wait-for graph for the following transaction scenario and determine whether a
deadlock exists.

(3 marks)

c. Consider the following contents of a LOG file and determine the


redo and undo list contents
(Start, T0)
(Write, T0, Interest, 6,8)
--------------------x1 crashed
(Commit, T0)
(Start, T1)
(Write, T1, Principle, 200, 400)
(Write, T1, Amount, 500, 600)
(Commit, T1)
(Start , T2)
(Write, T2, Interest, 6, 9)
--------------------x2 crashed
(commit, T2)
(Start , T3)
(Write, T3, Interest, 6, 11)
(Abort, T3) (4 marks)
Total marks : 10 marks

Q.2 Set. (B)


a. Consider the following two transactions:
TsalAD: write(accno)
read(salary);
read(allowance);
read(jobstatus);
if jobstatus = 1 then salary := salary+ allowance;
else salary := salary + 300;
write(salary);
TsalIT : write(accno)
read(salary);
read(allowance);
read(jobstatus);
write(salary);
Add lock and unlock instructions to transaction TsalIT and TsalAD, so that they observe the
two-phase locking protocol. Can the execution of these transactions result in a deadlock?
(4 marks)
b. Consider the transactions t1, t2 and t3 and a schedule S given below.
S : read1(A); read2 (B); write1(C); read3(B); read3(C); write2 (B); write3(A) Where
the subscript denotes the transaction number. Assume that the time stamp of t1<t2<t3.
Using time-stamp ordering scheme for concurrency control find out if the schedule will
go through. If there is to be a rollback, which transaction(s) will be rolled back?
(4 marks)
c. Check if deadlock occurs or not?

(2 mark)
Total marks : 10 marks.
Q.2 Set. (C)
a. Consider the execution shown below. Determine Undo and redo list
(Be precise about the points at which Undo begins and ends.)

(4 marks)

b. Consider the following diagram below

i)If the system fails repeatedly during recovery, what is the maximum number of log
records that can be written (as a function of the number of update and other log records
written before the crash) before restart completes successfully? (3 marks)
ii)What is the oldest log record that we need to retain? (3 marks)
Total marks : 10 marks.
Q.3 Set. (A) Albania data are designing backend for an Employee -payroll systems at JK
company.
They have to maintain employee records, different departments, Attendance , update
payrolls and generate monthly pay slip. There are some people who would use the DB
and they are employee, administrator, manager of each department and finally
accountant of JK. How do we implement this
Employee Can only see that data
Manager of a department Changes the attendance if employee reports
late for duty
Administrator Maintains whole db
Accountant Deals with salary of all employee and
generates pay slip.
What all database objects are required like SP, Triggers, forms and others
(7 marks)
Total marks: 7 marks.
Q.3 Set. (B) NM DB designers are designing backend for an Customer systems at JK ISP
company which has huge client base and they cater to broadband, mobile phone
connections .
They have to maintain customer records, different packages for each service , Bill
reminders, technical issues and complaints and generate monthly bill. There are some
people who would use the DB and they are manager, senior tech, supervisor and
customer service person of JK. How do we implement this
Manager Can make changes if needed
Senior Tech Fixes the technical issues in any service and
update the db
Supervisor Can correct the bill if wrongly computed or if
customers concern is legit
Customer service person Deals with customer query and so this person
can only view data.
What all database objects are required like SP, Triggers, forms and others
(7 marks)
Total marks: 7 marks.
Q.3 Set. (C) UNIVAC DB are designing backend for Attendence-payroll systems at CA
University.
They have to maintain employee records, different departments, Attendance , update
payrolls and generate monthly pay slip. There are some people who would use the DB
and they are Employee are faculty and technical and non technical staffs, administrator,
manager of each department and finally accountant of CA Uni. How do we implement
this
Employee Can only see that data
Manager of a department Changes the attendance if employee reports
late for duty
Administrator Maintains whole db
Accountant Deals with salary of all employee and
generates pay slip.
What all database objects are required like SP, Triggers, forms and others.
(7 marks)
Total marks: 7 marks.
Q.4 Set. (A) Consider the following SQL statement:
SELECT lname
FROM employee, works on, project
WHERE pname='Aquarius' and pnumber=pno and essn=ssn
and bdate > '1957-12-31';
Suppose the selection cardinalities (number of tuples in the resulting relation after ap-
plying the selection operation) for all selection conditions in the above WHERE clause
are as follows.

For the following query, prepare the initial (canonical) query tree, then show how the query tree
is optimized by the use of heuristic optimization.
a. Draw the query tree. (5 marks)
b. Draw the heuristic optimization tree. (5 marks)
Total marks: 10 marks.

Q.4 Set. (B) Consider the following SQL query that _nds all applicants who want to major in
CSE, live in Seattle, and go to a school ranked better than 10 (i.e., rank < 10).

And assuming:
_ Each school has a unique rank number (srank value) between 1 and 100.
_ There are 20 different cities.
_ Applicants.sid is a foreign key that references Schools.sid.
_ Major.id is a foreign key that references Applicants.id.
_ There is an unclustered, secondary B+ tree index on Major.id and all index pages are in
memory.
Compare the cost of two different query plans for the following query:
SELECT A.name
FROM Applicants A, Schools S, Major M
WHERE A.sid = S.sid AND A.id = M.id
AND A.city = 'Seattle' AND S.rank < 10 AND M.major = 'CSE'

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:
Select Fname, Dname from Employee e, Department d where e.dno = d.dnumber and salary
<180000;

Total marks : 10 marks

Q.5 Set. (A) Consider an the application that tracks session management, serving ad content, or
for managing user and product profiles. 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 like Twitter you store the user profile, their tweets and
the replies to their tweets. Also what all other tweets this user replied and some
recent tweets of the corresponding users. Note that user profile will have a set of
attributes, however, the set of attributes present might vary from one user to
another (e.g., some users won't provide DOB, where some user might not reveal
political affiliation, and so on).
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 stores health tracker data and uses this data for further
prcessing.
Describe the schema required for the above application using NoSQL database.
Which NoSQL Database can be used? Total : 8 marks

******

You might also like