Professional Documents
Culture Documents
G. Raschia
December 11, 2017
Examination Instructions
• The exam duration is of 1h30.
• A handwritten double-sided A4 sheet of paper is allowed.
• The exam is closed notes/documents/class book.
• The exam is closed electronic devices: mobile phone, laptop, tablet PC, etc.
• English to/from Native language dictionary is allowed.
• The exam has 5 exercises and 21 questions, up to a total of 40 points.
Grade Policy
Exercise 1 (Knowledge Test) is rewarded 16 points. Then, you must hunt for 14 more
points into the 4 subsequent exercises in order to reach a maximum grade of 30 points
(over 40 available). In other words, you can answer as many questions as you like from
exercises 2 to 5, but they will be globally rewarded 14 points maximum.
Write answers after each question in the devoted area. If your answer requires
more space, please follow on at the end of the exam paper.
1
Solution: If 2 tuples agree on X in R then they must agree on Y . We denote
the functional dependency by X → Y .
(2) 2. Write the equality generating dependency (egd) counter-part of the functional depen-
dency AB → C in relation R(ABCD).
Solution:
∀x, y, z, t : R(x, y, z, _) ∧ R(x, y, t, _) ⇒ z = t
(2) 3. Express in natural language (English) the following Conjunctive Query (CQ) against
the database Sells(bar,beer,price) that stores records about “a bar that sells a
beer at a given price”:
.................................................................................
.................................................................................
.................................................................................
.................................................................................
.................................................................................
Solution: Pairs of bars that sell the same beer such like the first bar charges a
lower price than the second one.
(2) 4. Show that the size, in total number of subgoals, of an unfolded query can grow
exponentially (Hints: consider views defined as union of CQ’s).
.................................................................................
.................................................................................
.................................................................................
.................................................................................
.................................................................................
where x̄i ’s and ȳ are tuples of constant and variables and Si ’s are relations of the
Source schemes and T is one single relation of the target schema. Hence, in the
GaV setting, each Global (Target) relation is described as a view on the Source
schemes.
(2) 7. How does the Tane algorithm work for pruning the search space?
.................................................................................
.................................................................................
.................................................................................
.................................................................................
.................................................................................
(2) 8. Give 3 more types of dependencies (other than functional dependency) in databases.
.................................................................................
.................................................................................
.................................................................................
.................................................................................
.................................................................................
Solution:
• etc.
1. AB → CD (in Σ)
2. C → EH (in Σ)
4. D → G (in F)
(2) 3. Give the sketch of a method to actually check for equivalence of 2 sets of FD’s
Solution: Σ1 ≡ Σ2 ⇔ Σ+ +
1 = Σ2 . But testing for the closure equality is insane!
Thus, it is much better to check for Σi |= Σj both ways. In other words:
1
The completness XΣ+ ⊆ W , the other way around, is much more tricky.
Solution: B belongs to any key (not part of any RHS). Keys are {AB, BC, BE}.
(2) 3. Decompose R up to Boyce-Codd Normal Form (BCNF). Tell whether the decompo-
sition is dependency-preserving or not.
(2) 4. Prove by the Chase Test that the decomposition is lossless join.
Perform a Bucket-like algorithm to find all the candidate rewritings of Q using views
V1 and V2 .
(2) 3. From the previous rewritings, give an equivalent query of Q if it exists, the maximally-
contained query otherwise.
展开四个Q,check是否与Q相等,注意细节,如果都不等,把所有Q的子集并起来作为最后的maximally contained query
1. Q1 (x, y) ← R(1, y), S(1, y), R(x, 1), S(x, 1): Q1 ⊆ Q but Q ̸⊆ Q1 since
S(1, y) subgoal of Q1 cannot map to any subgoal of Q.
2. Q2 = Q1 : nothing to do.
3. Q3 (x, y) ← R(1, 1), R(x, 1), S(x, 1): Q3 ⊆ Q but Q ̸⊆ Q3 since R(1, 1)
subgoal of Q3 cannot map to any subgoal of Q. Note that y/1 substitution
is allowed (not 1/y) since 1 is a constant.
4. Q4 = Q3 : nothing to do.
Finally, we stay with 2 rewritings that are contained into Q but no equivalent
query. Hence, the maximally-contained rewriting of Q is the union of Q1 and Q3 .
∀y : U (y) ⇒ ∃z : T (y, z)
∀x, y : W (x, y) ⇒ T (y, x)
Solution:
Then, a universal solution would be {T (0, 1), T (2, 0), T (3, y)}.
M:mapping
Solution: Certain answers to Q1 are {(0, 1), (2, 0)} and certain answers to Q2
are {0, 2, 3}.
(2) 3. Show a source instance r0 for which no universal solution exists, assuming the above
dependencies.
Solution: It suffices to show an instance that would violate the target depen-
dency. An easy one would be {W (0, 1), W (1, 1)} since T (0, 1) and T (1, 1) cannot
coexist.