install number 12 answers to puzzle corner problems (installment number 7-11) 中正大學資管所...
TRANSCRIPT
![Page 1: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/1.jpg)
INSTALL NUMBER 12Answers to Puzzle Corner Problems(Installment Number 7-11)
中正大學資管所碩一 690530023
郭 溥 淵
![Page 2: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/2.jpg)
IntroductionIntroduction
Reading review(Installment 7-11) The DEE and DUM problem The empty argument problem The general unification theorem Expression transformation problem Technical correspondence Conclusion Q&A
![Page 3: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/3.jpg)
Reading review(Installment 7-11)
Installment 7: Table with no columns Installment 8: Empty bag and identity crises Installment 9: The power of the keys Installment 10: Expression transformation Installment 11: Expression transformation
![Page 4: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/4.jpg)
The DEE and DUM problem
Source:”Tables with No Columns” (Installment 7)
Problem statement: What are the effects of DEE and DUM on the relational algebra operation union,intersection, difference, restrict, project, division, extend, and summarize?
![Page 5: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/5.jpg)
The DEE and DUM problem Solution:
Union
DEE DUM
DEE DEE DEE
DUM DEE DUM
OR 1 0
1 1 1
0 1 0
![Page 6: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/6.jpg)
The DEE and DUM problem Solution:
Intersection DEE DUM
DEE DEE DUM
DUM DUM DUM
AND 1 0
1 1 0
0 0 0
![Page 7: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/7.jpg)
The DEE and DUM problem Solution:
Difference DEE DUM
DEE DUM DEE
DUM DUM DUM
AND NOT
1 0
1 0 1
0 0 0
![Page 8: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/8.jpg)
The DEE and DUM problem
Solution of restrict and project:• Any restriction of DEE yields DEE if the
restriction condition is true, DUM if it is false.
• Any restriction of DUM yields DUM.
• Projection of any_table over no columns yields DUM if the original table is empty, DEE otherwise. In particular, projection of DEE or DUM, necessarily over no columns at all, return its input.
![Page 9: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/9.jpg)
The DEE and DUM problem
Solution of division:• Any table T divided by DEE yields T.
• Any table T divided by DUM yields an empty table with the same heading as T.
• DEE divided by any table T yields T.
• DUM divided by any tale T yields an empty table with the same heading as T.
• Any nonempty table divided by itself yields DEE. An empty table divided by itself yields DUM.
![Page 10: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/10.jpg)
The DEE and DUM problem
Solution of extend and summarize:• Extending DEE or DUM to add a new column
yields a relation of one column and the same number of rows as its input.
• Summarizing DEE or DUM(necessarily over no columns at all) yields a relation of one column and the same number of rows as input.
![Page 11: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/11.jpg)
The empty argument problem
Source:”Empty Bags and Identity crises” (Installment 8)
Problem statement: Give the correct “empty argument” treatment for each of the following functions. Note: In Case 1-4 the argument is intended to be a bag of number; in Case 5-6 it is a bag of tables all having the same(specified) heading.
![Page 12: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/12.jpg)
The empty argument problem
1. Sum of the squares
Solution:
0
2.Standard deviation
Solution:
Undefined
![Page 13: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/13.jpg)
The empty argument problem
3. Median
Solution:
Undefined
4.Geometric mean
Solution:
1
![Page 14: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/14.jpg)
The empty argument problem
Source:”Empty Bags and Identity crises” (Installment 8)
Problem statement: Give the correct “empty argument” treatment for each of the following functions. Note: In Case 1-4 the argument is intended to be a bag of number; in Case 5-6 it is a bag of tables all having the same(specified) heading.
![Page 15: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/15.jpg)
The empty argument problem
5. UnionSolution:
An empty table with the specified heading.
6.Intersection Solution:
A table with the specified heading and with body equal to the Cartesian product to all underlying domains.
![Page 16: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/16.jpg)
The empty argument problem
SELECT CURRENT_TIME
WHERE 1=0 ;
EXTEND DUM ADD CURRENT_TIME AS X
Those two query are equivalent.
![Page 17: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/17.jpg)
The general unification theorem
Source:”The power of keys” (Installment 9)
Problem statement: Darwen’s work on FD and key inheritance makes use of the following theorem. Let A, B, C, and D be subsets of the set of columns of relation R such that AB and CD. Then A∪(C-B)B∪D . Prove this theorem.
![Page 18: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/18.jpg)
The general unification theorem
Solution:• Self-determination: AA
• Joint dependence: AB&AC≡AB∪C
• Transitivity: AB&BC ==> AC
• Composition: AB&CD ==>A∪CB∪D
![Page 19: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/19.jpg)
The general unification theorem Solution:
1. AB (given)2.CD (given)3.AB∩C (by joint dependence and 1)4.C-BC-B (self-determination)5.A∪(C-B)(B∩C)∪(C-B)
(by composition, 3, 4)
6.A∪(C-B)C (simplifying 5)7.A∪(C-B)D (by transitivity, 6, 2) 8. A∪(C-B)B∪D (by composition, 1,
7)
![Page 20: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/20.jpg)
The general unification theorem
Solution:
1. AB (given)
2.CD (given)3.AB∩C (by joint dependence
and 1) why? 因為 AB,又 B∩C屬於 B 的一部
份, 故 AB∩C。
![Page 21: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/21.jpg)
The general unification theorem
Solution:
4.C-BC-B (self-determination)
5.A∪(C-B)(B∩C)∪(C-B) (by composition, 3,
4) why?Composition: AB&CD ==>A∪CB∪D
AB∩C ---3 C-BC-B ---4故 A∪(C-B)(B∩C)∪(C-B)
![Page 22: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/22.jpg)
The general unification theorem
Solution:6.A∪(C-B)C (simplifying 5) why?
(B∩C)∪(C-B)就是 C 所以 A∪(C-B)C7.A∪(C-B)D (by transitivity, 6, 2) why?
因為 A∪(C-B)C ,又 CD所以 A∪(C-B)D
![Page 23: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/23.jpg)
The general unification theorem
Solution:8. A∪(C-B)B∪D (by composition,1,7) why?
Composition: AB&CD ==>A∪CB∪D
AB ---1A∪(C-B)D ---2
所以 A∪(C-B)B∪D
完成證明
![Page 24: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/24.jpg)
Expression transformation problem
Source:”Expression Transformation” (Installment 10 & 11)
Problem statement:Prove the following statements
• A sequence of restrictions against a given relation can be transformed into a single restriction.
• A sequence of projections against a given relation can be transformed into a single projection.
• A restriction of a projection can be transformed into a restriction.
![Page 25: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/25.jpg)
Expression transformation problem
Solution:(a)
• ( R WHERE C1 ) WHERE C2
• R WHERE C1 AND C2
If C1 and C2 are both restriction condition for relation R, then above two expressions are obviously equivalent.
![Page 26: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/26.jpg)
Expression transformation problem
Solution:(b)
• ( R [ L1 ] ) [L2]
• R [ L2 ]
If L1 is a subset of the heading of relation R and L2 is a subset of L1,then the above two expressions are obviously equivalent.
![Page 27: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/27.jpg)
Expression transformation problem
Solution:(c)
• R [ L ] WHERE C
• ( R WHERE C ) [ L ]
If L and C are, respectively, a subset of heading of relation R and restriction condition for relation R that involves only columns mentioned in L, then the above two expressions are obviously equivalent.
![Page 28: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/28.jpg)
Expression transformation problem
SELECT E#
FROM DEPT, EMP
WHERE NOT ( DEPT.D# = EMP.D#
AND EMP.D# = ‘D1’) ; Show the answer
DEPT EMP D#
D2
E# D#
E1 --
![Page 29: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/29.jpg)
Expression transformation problem
(a) Show the correct real-world answer to this query.
DEPT EMP D#
D2
E# D#
E1 --
![Page 30: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/30.jpg)
Expression transformation problem
SELECT E#FROM DEPT, EMPWHERE NOT ( DEPT.D# = EMP.D#
AND EMP.D# = ‘D1’) ; Show the answer
DEPT EMP
The answer is E1.
D#
D2
E# D#
E1 --
![Page 31: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/31.jpg)
Expression transformation problem
(b) Show the answer delivered by the query as stated.
DEPT EMP D#
D2
E# D#
E1 --
![Page 32: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/32.jpg)
Expression transformation problem
SELECT E#FROM DEPT, EMPWHERE NOT ( DEPT.D# = EMP.D#
AND EMP.D# = ‘D1’) ; Show the answer
DEPT EMP
The answer is empty.
D#
D2
E# D#
E1 --
![Page 33: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/33.jpg)
Expression transformation problem
SELECT E#
FROM DEPT, EMP
WHERE NOT ( DEPT.D# = EMP.D#
AND EMP.D# = ‘D1’) ; Show the answer
DEPT EMP D#
D2
E# D#
E1 --
![Page 34: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/34.jpg)
Expression transformation problem
(c) Show the answer delivered if the optimizer applies “predicate transitive closure”.
DEPT EMP D#
D2
E# D#
E1 --
![Page 35: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/35.jpg)
Expression transformation problem
Optimizer will transform the expression to :SELECT E#FROM DEPT,EMPWHERE NOT ( DEPT.D# = EMP.D#
AND EMP.D# = D1AND DEPT.D# = D1 )
;
The answer is E1.
![Page 36: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/36.jpg)
Technical correspondence
Problem:
• SUMMARIZE EMP BY ( D# )
ADD AVG ( SAL )
AS AVGSAL
![Page 37: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/37.jpg)
Technical correspondence
Solution:• IF exp1 THEN exp2 ELSE exp3
• SUMMARIZE EMP BY ( D# )
ADD ( IF IS_EMPTY ( EMP ) THEN 0
ELSE AVG ( SAL ) )
AS AVGSAL
![Page 38: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/38.jpg)
Conclusion
![Page 39: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/39.jpg)
Q&A
![Page 40: INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 690530023 郭 溥 淵](https://reader036.vdocuments.site/reader036/viewer/2022082217/5697bff91a28abf838cbff52/html5/thumbnails/40.jpg)
Thanks for your listening.