Laptop-Printer Extra
Laptop-Printer Extra
Laptop-Printer Extra
Test 2A
Instructor: Son Cao Tran
________________________________________________________________________
Name:
SSN:
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Directions:
The test has 4 questions, each worth as indicated, there is more than 20 points.
Read the question carefully and answer only what is asked
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
1. (3.5 points) Consider a relation schema R(X,Y,Z,P,Q) with the following functional
dependencies:
XY → P, P → Z, and XP → Q
{P}+ = {P, Z}
{X, P}+ = {X, P, Q, Z}+
=> {P}, {X, P} are not superkey. Notice also that no key in R contains Q or Z.
=> P→Ζ and XP→Q violate 3NF condition.
b) No, because there are functional dependencies in R that violate the 3NF condition.
2. (3.5 points) Consider the relation schema R(X,Y,Z,P,Q) with the following
multivalued dependencies (MD)
Y →→ X and YX →→ Z
functional dependencies
Y → P and YX → Q.
a) Y →→ P and YX →→ Q
violate the 4NF condition because all of them are nontrivial and the left hand side is not a
superkey.
c) No
d) Takes YX →→ Q we have
(Y, X, Q) and (Y, X, Z, P)
So, the final decomposition: (Y, X), (Y, Q), (Y, Z), (Y, P).
Notes: There might be different ways to decompose R into 4NF. If you solution is right, it
will be graded correctly!
3. (7 points) Suppose that we have the following relational database schemas
Product(maker, model)
PC(model, speed, ram, hd, cd, price)
Laptop(model, speed, ram, hd, screen, price)
Printer(model, color, type, price)
with the assumption that model number are unique over all manufacturer and product
types. This means that the above four relations have model as one of their keys.
a) Πmaker (R S) Πmaker (R T)
speed >=1.3
(R S) )
R2= Πmaker, model (
speed>=1.3
(R T) )
R3 = R1 R2, R4 = R3
R5 = R3.maker = R4.maker and R3.model<>R4.model (R3 x R4)
Πmaker (R5)
c) Πmaker (R U) − Πmaker (R T)
d) Πmodel, price (S) Πmodel, price (T) Πmodel, price (U)
R2.speed >R3.speed
(R2 x R3) ) Πspeed (
Product(maker, model)
PC(model, speed, ram, hd, cd, price)
Laptop(model, speed, ram, hd, screen, price)
Printer(model, color, type, price)
with the assumption that model number are unique over all manufacturer and product
types. This means that the above four relations have model as one of their keys.
a) select maker
from product, pc
where product.model = pc.model
intersect
select maker
from product, laptop
where product.model = laptop
b) select avg(price)
from pc, product
where pc.model = product.model and maker=’A’;
select maker
from pmaker
group by maker
having count (model) >=2
d) select maker
from product p,pc
where p.model=pc.model
group by maker
having count(distinct (speed))>=4;
e) select maker
from product p,pc
where p.model=pc.model
group by maker
having count(distinct (model)) =4;
The test has 4 questions, each worth as indicated, there is more than 20 points.
Read the question carefully and answer only what is asked
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
5. (3.5 points) Consider a relation schema R(P,Q,M,N,E) with the following functional
dependencies:
PQ → N, N → M, and PN → E
{N}+ = {N, M}
{P, N}+ = {P, N, E, M}+
=> {N}, {P,N} are not superkey. Notice also that no key in R contains M or E.
=> N→M and PN→E violate 3NF condition.
b) No, because there are functional dependencies in R that violate the 3NF condition.
6. (3.5 points) Consider the relation schema R(P,Q,M,N,E) with the following
multivalued dependencies (MD)
Q →→ P and QP →→ M
functional dependencies
Q → N and PQ → E.
a) Q →→ N and PQ →→ E
violate the 4NF condition because all of them are nontrivial and the left hand side is not a
superkey.
c) No
d) Takes PQ →→ E we have
(P, Q, E) and (P, Q, M, N)
So, the final decomposition: (Q, P), (Q, E), (Q, N), (Q, M).
Notes: There might be different ways to decompose R into 4NF. If your solution is right,
it will be graded correctly !
7. (7 points) Suppose that we have the following relational database schemas
Product(maker, model)
PC(model, speed, ram, hd, cd, price)
Laptop(model, speed, ram, hd, screen, price)
Printer(model, color, type, price)
with the assumption that model number are unique over all manufacturer and product
types. This means that the above four relations have model as one of their keys.
a) Πmaker (R U) Πmaker (R T)
c) Πmaker (R U) − Πmaker (R S)
hd>=1.3
S) )
R2= Πmaker, model ( hd>=1.3 (R T) )
R3 = R1 R2, R4 = R3
R5 = R3.maker = R4.maker and R3.model<>R4.model (R3 x R4)
Πmaker (R5)
R2.speed >R3.speed
(R2 x R3) ) Πspeed (
Product(maker, model)
PC(model, speed, ram, hd, cd, price)
Laptop(model, speed, ram, hd, screen, price)
Printer(model, color, type, price)
with the assumption that model number are unique over all manufacturer and product
types. This means that the above four relations have model as one of their keys.
a) select maker
from product, printer
where product.model = printer.model
intersect
select maker
from product, laptop
where product.model = laptop
select maker
from pmaker
group by maker
having count (distinct model) >=2
c) select avg(price)
from pc, product
where pc.model = product.model and maker=’C’;
d) select maker
from product p,pc
where p.model=pc.model
group by maker
having count(distinct (speed))>=4;
e) select maker
from product p,pc
where p.model=pc.model
group by maker
having count(distinct (model)) =4;