Você está na página 1de 5

ADB TEST 2003/2004

QUESTIONS ABOUT SQL and RELATIONAL ALGEBRA


Using the attached version of the HATHOSP database with which you are familiar.
Q1 What is the cardinality ( i.e. how many rows are there in the resulting relation) of
(0.5 marks)
select pno, pname
from patient p, dose d
where p.pno = d.pno
and d,dno = d7;
a)
b)
c)
d)
e)

0
3
5
10
13

the correct answer is b


Q2 What is the cardinality ( i.e. how many rows are there in the resulting relation) of
(0.5 marks)
select pno, pname
from patient p, dose d
where p.pno = d.pno
and d.dno != d7;
a)
b)
c)
d)
e)

0
3
5
10
13

the correct answer is d: find the pno and pnames of patients who have been given a drug
which is not d7.
Q3 Consider the following relational algebra expression in which the word join stands
for a NATURAL JOIN:
(1 mark)

dno, dname (drug join (pno= p1(dose)))


Which of the following expressions is equivalent to the expression given above
a)
b)
c)
d)

dno, dname (dose join (pno= p1(drug)))


(pno= p1(dno, dname (drug join dose))
dno, dname (pno= p1(drug join dose))
(dno, dname (drug)) join (pno= p1(dose))

e) none of these
correct answer is c :
a) there is no pno in drug
b) the scheme of (dno, dname (drug join dose)) is (dno, dname) and so there is no pno to
apply the select to.
c) is correct
d) the intermediate schemes would be (dno, dname) join (pno, dno, dosedate, qty )
giving a final scheme (dno, dname, pno, dosedate, qty )
e) no correct as c is OK

QUESTIONS ABOUT NORMALISATION


The Patient relation is extended such that general practitioners now have an identifying
number (gpno) as well as a name (gpname)
Patient (pno, pname, title, DOB, children, gpno, gpname)
FDs

pno pname
pno title
pno DOB
pno children
pno gpno
gpno gpname

Q4 Which one of the following decompositions of patient is NOT lossless ( i.e.


decomposition is lossy )
(1 mark)
a)
b)
c)
d)
e)

R1(pno, pname, title, DOB), R2 (pno, children, gpno, gpname)


R1 (pno, pname, title, DOB, children, gpno) , R2 (gpno, gpname)
R1 ( pno, pname, title, DOB, children), R2 (gpno, gpname)
More than one of the above
None of the above

Correct answer c
R1 join R2 in c) would be the Cartesian product of R1 and R2 which gives us
spurious tuples
a) is fine it is not lossy although it is not normalised
b) is fine ( and is also normalised)
Q5 Which one of the following decompositions of patient is a lossless AND in BCNF
(1 mark)
a) R1(pno, pname, title, DOB), R2 (pno, children, gpno, gpname)
b) R1 (pno, pname, title, DOB, children, gpno) , R2 (gpno, gpname)
c) R1 ( pno, pname, title, DOB, children), R2 (gpno, gpname)
d) More than one of the above

e) None of the above


Correct answer b)
a) is not normalised as gpno is not a superkey to R2
c) is not lossless
Q6
(1 mark)
The following all key relation is concerned with childrens parties, childrens entertainers,
and the skills the entertainers have (conjuring, Punch and Judy shows etc) .
Parties ( party-id, entertainer, skill)
In which of the following circumstances is Parties already in 4NF (i.e. it should NOT be
further decomposed):
a tuple { p1, Beezer, juggling} in Parties means that
a) the entertainer called Beezer was at the party identified by the number p1 and
entertained the children by juggling.
b) the entertainer called Beezer was at the party identified by the number p1 and one of
Beezers skills is juggling.
c) the entertainer called Beezer was at the party identified by the number p1 and party
p1 required a juggler
d) more than one of the above
e) none of the above
correct answer a) it is one complex fact
b) and c) we are not told that Beezer did juggle at party p1 if we split the relations into
two we will generate this fact when we join the two relations.
Q7 Consider the same relation scheme

(1 mark)

Parties ( party-id, entertainer, skill)


Under which circumstance below is Parties is definitely NOT in 5NF (and therefore
should be split into three relations) . We want to record what skills Beezer is actually
using at party p1 and
a) although Beezer is at party p1 and Beezer can do conjuring tricks, and party p1
wants conjuring tricks, Beezer may not do any conjuring tricks at party (he will
juggle etc.)
b) if Beezer is at party p1, and he can juggle, and they want a juggler at party p1 then
Beezer will juggle at party p1
c) one of Beezers skills is juggling, Beezer is at party p1, party p1 wants a juggler
d) more than one of the above
e) none of the above
correct answer b) the only one in which the final fact ( which will be generated by the
joins) is actually true.

QUESTIONS ABOUT THE CLOSURE ALORITHM


Q8
Given Relation R (A,B,C,D,E) with FDs {AB, AC, CD, CE)

(1 mark)

Which of the following is true


a) A is a superkey and a candidate key
b) A is a superkey but not a candidate key
c) C is a superkey and a candidate key
d) C is a superkey but not a candidate key
e) none of these
correct answer a)
Q9 Given R (A,B,C,D,E,F)
with FDs {

(1 mark)
AD B
BD
DF
FE

which of the following is correct


a)
b)
c)
d)
e)

The closure of CB is CBDFE


The closure of EF is EFD
The closure of BF is BEF
The closure of BD is BDAEF
none of the above

correct answer a)
closure of EF is EF
closure of BF is BFDE
closure of DB is DBFE
Q10 Given R (A, B, C, D, E, F)
with FDs {
AB
BE F
DC
FE

(1 mark)

which of the following statements is correct


a)
b)
c)
d)
e)

the following are all superkeys to R: ABFED, ABDF, BED


ADF and ADE are both superkeys to R but neither is a candidate key
ADF and ADE are both candidate keys
One but not both of ADF and ADE is a candidate key
none of the above

correct answer c)

QUESTIONS ABOUT TRANSACTIONS


Q11 The following schedule

(1 mark)

r1 (X); r2(Z); r1 (Z); r3 (X); r3(Y); w1 (X); w3(Y); r 2 (Y); w2 (Z); w2 (Y);
is
a)
b)
c)
d)
e)

not conflict serializable


equivalent to the serial schedule T2 followed by T1 followed by T3
equivalent to the serial schedule T3 followed by T2 followed by T1
equivalent to the serial schedule T3 followed by T1 followed by T2
none of the above

correct answer d)
Q 12
(1 mark)
Look at the attached diagram which shows what happens when a transaction requests a
lock. The labels 1, 2 and 3 should be replaced with
a)
b)
c)
d)
e)

1 = currently Xlocked, 2= currently locked, 3 = empty wait queue


2 = currently Xlocked, 1= currently locked, 3 = empty wait queue
3 = currently Xlocked, 1= currently locked, 2 = empty wait queue
3 = currently Xlocked, 2= currently locked, 1 = empty wait queue
none of these

correct answer c)

Você também pode gostar