ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ

Σχετικά έγγραφα
Lecture 23: Functional Dependencies and Normalization

EE512: Error Control Coding

2 Composition. Invertible Mappings

Homework 3 Solutions

Principles of Database Systems

Διδάσκων: Παναγιώτης Ανδρέου

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

Section 8.3 Trigonometric Equations

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

CRASH COURSE IN PRECALCULUS

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Matrices and Determinants

A Note on Intuitionistic Fuzzy. Equivalence Relation

The challenges of non-stable predicates

Example Sheet 3 Solutions

derivation of the Laplacian from rectangular to spherical coordinates

Section 7.6 Double and Half Angle Formulas

Fractional Colorings and Zykov Products of graphs

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in

Areas and Lengths in Polar Coordinates

CHAPTER 48 APPLICATIONS OF MATRICES AND DETERMINANTS

C.S. 430 Assignment 6, Sample Solutions

Areas and Lengths in Polar Coordinates

Every set of first-order formulas is equivalent to an independent set

CHAPTER 101 FOURIER SERIES FOR PERIODIC FUNCTIONS OF PERIOD

Lecture 2. Soundness and completeness of propositional logic

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ. ΕΠΛ342: Βάσεις Δεδομένων. Χειμερινό Εξάμηνο Φροντιστήριο 10 ΛΥΣΕΙΣ. Επερωτήσεις SQL

Approximation of distance between locations on earth given by latitude and longitude

Concrete Mathematics Exercises from 30 September 2016

Inverse trigonometric functions & General Solution of Trigonometric Equations

Διδάσκων: Παναγιώτης Ανδρέου

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

ST5224: Advanced Statistical Theory II

( ) 2 and compare to M.

ORDINAL ARITHMETIC JULIAN J. SCHLÖDER

PARTIAL NOTES for 6.1 Trigonometric Identities

The Simply Typed Lambda Calculus

Finite Field Problems: Solutions

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

b. Use the parametrization from (a) to compute the area of S a as S a ds. Be sure to substitute for ds!

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Homework 8 Model Solution Section

Second Order Partial Differential Equations

Problem Set 3: Solutions

2. THEORY OF EQUATIONS. PREVIOUS EAMCET Bits.

Reminders: linear functions

Math221: HW# 1 solutions

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

6.3 Forecasting ARMA processes

Srednicki Chapter 55

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

Lecture 22: Functional Dependencies and Normalization

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι

Strain gauge and rosettes

9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr

4.6 Autoregressive Moving Average Model ARMA(1,1)

Math 6 SL Probability Distributions Practice Test Mark Scheme

Fourier Series. MATH 211, Calculus II. J. Robert Buchanan. Spring Department of Mathematics

Other Test Constructions: Likelihood Ratio & Bayes Tests

Solutions to Exercise Sheet 5

k A = [k, k]( )[a 1, a 2 ] = [ka 1,ka 2 ] 4For the division of two intervals of confidence in R +

Right Rear Door. Let's now finish the door hinge saga with the right rear door

Section 9.2 Polar Equations and Graphs

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

the total number of electrons passing through the lamp.

Partial Trace and Partial Transpose

Exercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1.

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

Math 446 Homework 3 Solutions. (1). (i): Reverse triangle inequality for metrics: Let (X, d) be a metric space and let x, y, z X.

Assalamu `alaikum wr. wb.

The Probabilistic Method - Probabilistic Techniques. Lecture 7: The Janson Inequality

( y) Partial Differential Equations

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

Mean-Variance Analysis

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 7η: Consumer Behavior Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών

ΣΧΕΔΙΑΣΜΟΣ ΒΑΣΕΩΝ ΔΕΔΟΜΕΝΩΝ ΚΑΙ ΚΑΝΟΝΙΚΟΠΟΙΗΣΗ. Σχεδιασμός Σχεσιακών ΒΔ και Κανονικοποίηση 1

Instruction Execution Times

Συστήματα Διαχείρισης Βάσεων Δεδομένων

Quadratic Expressions

MATH423 String Theory Solutions 4. = 0 τ = f(s). (1) dτ ds = dxµ dτ f (s) (2) dτ 2 [f (s)] 2 + dxµ. dτ f (s) (3)

Appendix to On the stability of a compressible axisymmetric rotating flow in a pipe. By Z. Rusak & J. H. Lee

1) Formulation of the Problem as a Linear Programming Model

Chapter 3: Ordinal Numbers

Statistical Inference I Locally most powerful tests

Uniform Convergence of Fourier Series Michael Taylor

Galatia SIL Keyboard Information

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

Lecture 26: Circular domains

[1] P Q. Fig. 3.1

TMA4115 Matematikk 3

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

= λ 1 1 e. = λ 1 =12. has the properties e 1. e 3,V(Y

Second Order RLC Filters

Solutions to the Schrodinger equation atomic orbitals. Ψ 1 s Ψ 2 s Ψ 2 px Ψ 2 py Ψ 2 pz

Transcript:

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΠΛ 342 Βάσεις εδοµένων ιδάσκων: Γ. Σαµάρας 5η σειρά ασκήσεων: Συναρτησιακές Εξαρτήσεις και Κανονικοποίηση. Λύσεις Μέρος Α. Συναρτησιακές Εξαρτήσεις 1. Αποδείξτε ή διαψεύστε τους ακόλουθους κανόνες. Μπορείτε να χρησιµοποιήστε τους κανόνες του Armstrong ή να δώσετε αντιπαράδειγµα. a. {W Y, X Z} = {WX Y } b. {X Y} και Z Y = { X Z } c. { X Y, X W, WY Z} = {X Z} d. {XY Z, Y W} = {XW Z} e. {X Z, Y Z} = {X Y} f. {X Y, XY Z} = {X Z} (a) {W ->Y, X ->Z} = {WX ->Y } Proof: (1) W ->Y (given) (2) X ->Z (given) (3) WX ->YX (using IR2 (augmentation) to augment (1) with X) (4) YX ->Y (using IR1 (reflexivity), knowing that Y subset-of YX) (5) WX ->Y (using IR3 (transitivity) on (3) and (4)) (b) {X ->Y} and Z subset-of Y = { X ->Z } Proof: (2) Y ->Z (using IR1 (reflexivity), given that Z subset-of Y) (3) X ->Z (using IR3 (transitivity) on (1) and (2)) (c) { X ->Y, X ->W, WY ->Z} = {X ->Z} Proof: (2) X ->W (given) (3) WY ->Z (given) (4) X ->XY (using IR2 (augmentation) to augment (1) with X) (5) XY ->WY (using IR2 (augmentation) to augment (2) with Y)

(6) X ->WY (using IR3 (transitivity) on (4) and (5)) (7) X ->Z (using IR3 (transitivity) on (6) and (3)) (d) {XY ->Z, Y ->W} = {XW ->Z} Disproof: X Y Z W t 1 =x 1 y 1 z 1 w 1 t 2 =x 1 y 2 z 2 w 1 The above two tuples satisfy XY ->Z and Y ->W but do not satisfy XW ->Z (e) {X ->Z, Y ->Z} = {X ->Y} Disproof: X Y Z t 1 =x 1 y 1 z 1 t 2 =x 1 y 2 z 1 The above two tuples satisfy X ->Z and Y ->Z but do not satisfy X ->Y (f) {X ->Y, XY ->Z} = {X ->Z} Proof: (2) XY ->Z (given) (3) X ->XY (using IR2 (augmentation) to augment (1) with X) (4) X ->Z (using IR3 (transitivity) on (3) and (2)) 2. Θεωρείστε τα ακόλουθα σύνολα συναρτησιακών εξαρτήσεων: F={A C, AC D, E AD, E H} και G={A CD, E AH}. Είναι ισοδύναµα; To show equivalence, we prove that G is covered by F and F is covered by G. Proof that G is covered by F: {A} + = {A, C, D} (with respect to F), which covers A ->CD in G {E} + = {E, A, D, H, C} (with respect to F), which covers E ->AH in G Proof that F is covered by G: {A} + = {A, C, D} (with respect to G), which covers A ->C in F {A, C} + = {A, C, D} (with respect to G), which covers AC ->D in F {E} + = {E, A, H, C, D} (with respect to G), which covers E ->AD and E ->H in F 3. Θεωρείστε το σχήµα EMP_DEPT της εικόνας 14.3(a) (από το επισυναπτόµενο φυλλάδιο) και το σύνολο συναρτησιακών εξαρτήσεων G = {SSN {ENAME, BDATE, ADDRESS, DNUMBER}, DNUMBER {DNAME, DMGRSSN} }. Βρείτε τις κλειστότητες (closures) των {SSN}+ και {DNUMBER}+ σε σχέση µε το G. {SSN} + ={SSN, ENAME, BDATE, ADDRESS, DNUMBER, DNAME, DMGRSSN}

4. Είναι το σύνολο συναρτησιακών εξαρτήσεων G της προηγούµενης άσκησης ελάχιστο (minimal); Αν όχι, δώστε ένα ελάχιστο σύνολο ισοδύναµο µε το G (αποδείξτε ότι είναι ισοδύναµο µε το G). The set G of functional dependencies in Exercise 4 is not minimal, because it violates rule 1 of minimality (every FD has a single attribute for its right hand side). The set F is an equivalent minimal set: F= {SSN->{ENAME},SSN->{BDATE}, SSN->{ADDRESS}, SSN ->{DNUMBER}, DNUMBER ->{DNAME}, DNUMBER->{DMGRSSN}} To show equivalence, we prove that G is covered by F and F is covered by G. Proof that G is covered by F: {SSN} + = {SSN, ENAME, BDATE, ADDRESS, DNUMBER, DNAME, DMGRSSN} (with respect to F), which covers SSN ->{ENAME, BDATE, ADDRESS, DNUMBER} in G (with respect to F), which covers DNUMBER ->{DNAME, DMGRSSN} in G Proof that F is covered by G: {SSN} + = {SSN, ENAME, BDATE, ADDRESS, DNUMBER, DNAME, DMGRSSN} (with respect to G), which covers SSN ->{ENAME}, SSN ->{BDATE}, SSN ->{ADDRESS}, and SSN ->{DNUMBER} in F (with respect to G), which covers DNUMBER->{DNAME} & DNUMBER->{DMGRSSN} in F 5. Ποιες ανωµαλίες ενηµέρωσης παρατηρείτε στις σχέσεις EMP_PROJ και EMP_DEPT των εικόνων 14.3 και 14.4 (από το επισυναπτόµενο φυλλάδιο); In EMP_PROJ, the partial dependencies {SSN}->{ENAME} and {PNUMBER}->{PNAME, PLOCATION} can cause anomalies. For example, if a PROJECT temporarily has no EMPLOYEEs working on it, its information (PNAME, PNUMBER, PLOCATION) will not be represented in the database when the last EMPLOYEE working on it is removed (deletion anomaly). A new PROJECT cannot be added unless at least one EMPLOYEE is assigned to work on it (insertion anomaly). Inserting a new tuple relating an existing EMPLOYEE to an existing PROJECT requires checking both partial dependencies; for example, if a different value is entered for PLOCATION than those values in other tuples with the same value for PNUMBER, we get an update anomaly. Similar comments apply to EMPLOYEE information. The reason is that EMP_PROJ represents the relationship between EMPLOYEEs and PROJECTs, and at the same time represents information concerning EMPLOYEE and PROJECT entities. In EMP_DEPT, the transitive dependency {SSN}->{DNUMBER}->{DNAME, DMGRSSN} can cause anomalies. For example, if a DEPARTMENT temporarily has no EMPLOYEEs working for it, its information (DNAME, DNUMBER, DMGRSSN) will not be represented in the database when the last EMPLOYEE working on it is removed (deletion anomaly). A new DEPARTMENT cannot be added unless at least one EMPLOYEE is assigned to work on it (insertion anomaly). Inserting a new tuple relating a new EMPLOYEE to an existing DEPARTMENT requires checking the transitive dependencies; for example, if a different value is entered for DMGRSSN than those values in other tuples with the same value for DNUMBER, we get an update anomaly. The reason is that EMP_DEPT represents the relationship between EMPLOYEEs and DEPARTMENTs, and at the same time represents information concerning EMPLOYEE and DEPARTMENT entities.

Μέρος Β. Κανονικοποίηση 6. Σε πια κανονική µορφή είναι το σχήµα LOTS της εικόνας 1.(a) (από το επισυναπτόµενο φυλλάδιο) σε σχέση µε τους ορισµούς των κανονικών µορφών που υπολογίζουν µόνο το πρωτεύων κλειδί (primary key); Θα ήταν στην ίδια κανονική µορφή αν χρησιµοποιούσατε τους γενικούς ορισµούς των κανονικών µορφών; If we only take the primary key into account, the LOTS relation schema in Figure 1(a) will be in 2NF since there are no partial dependencies on the primary key. However, it is not in 3NF, since there are the following two transitive dependencies on the primary key: PROPERTY_ID# ->COUNTY_NAME ->TAX_RATE, and PROPERTY_ID# ->AREA ->PRICE. Now, if we take all keys into account and use the general definition of 2NF and 3NF, the LOTS relation schema will only be in 1NF because there is a partial dependency COUNTY_NAME ->TAX_RATE on the secondary key {COUNTY_NAME, LOT#}, which violates 2NF. 7. Αποδείξτε ότι κάθε σχέση µε µόνο δυο χαρακτηριστικά είναι σε BCNF. Consider a relation schema R={A, B} with two attributes. The only possible (non-trivial) FDs are {A} ->{B} and {B} ->{A}. There are four possible cases: (i) No FD holds in R. In this case, the key is {A, B} and the relation satisfies BCNF. (ii) Only {A} ->{B} holds. In this case, the key is {A} and the relation satisfies BCNF. (iii) Only {B} ->{A} holds. In this case, the key is {B} and the relation satisfies BCNF. (iv) Both {A} ->{B} and {B} ->{A} hold. In this case, there are two keys {A} and {B} and the relation satisfies BCNF. Hence, any relation with two attributes is in BCNF. 8. Θεωρείστε το ακόλουθο σχήµα R = {A, B, C, D, E, F, G, H, I} και το σύνολο συναρτησιακών εξαρτήσεων F = { {A, B} {C}, {A} {D, E}, {B} {F}, {F} {G, H}, {D} {I, J} }. Πιο είναι το κλειδί του R? Αποσυνθέστε το R σε σχέσεις 2NF, και µετά σε σχέσεις 3NF. A minimal set of attributes whose closure includes all the attributes in R is a key. (One can also apply algorithm 15.4a (see chapter 15 in the textbook)). Since the closure of {A, B}, {A, B}+ = R, one key of R is {A, B} (in this case, it is the only key). To normalize R intuitively into 2NF then 3NF, we take the following steps (alternatively, we can apply the algorithms discussed in Chapter 15): First, identify partial dependencies that violate 2NF. These are attributes that are functionally dependent on either parts of the key, {A} or {B}, alone. We can calculate the closures {A}+ and {B}+ to determine partially dependent attributes: {A}+ = {A, D, E, I, J}. Hence {A} -> {D, E, I, J} ({A} -> {A} is a trivial dependency) {B}+ = {B, F, G, H}, hence {A} -> {F, G, H} ({B} -> {B} is a trivial dependency)

To normalize into 2NF, we remove the attributes that are functionally dependent on part of the key (A or B) from R and place them in separate relations R1 and R2, along with the part of the key they depend on (A or B), which are copied into each of these relations but also remains in the original relation, which we call R3 below: R1 = {A, D, E, I, J}, R2 = {B, F, G, H}, R3 = {A, B, C} The new keys for R1, R2, R3 are underlined. Next, we look for transitive dependencies in R1, R2, R3. The relation R1 has the transitive dependency {A} -> {D} -> {I, J}, so we remove the transitively dependent attributes {I, J} from R1 into a relation R11 and copy the attribute D they are dependent on into R11. The remaining attributes are kept in a relation R12. Hence, R1 is decomposed into R11 and R12 as follows: R11 = {D, I, J}, R12 = {A, D, E} The relation R2 is similarly decomposed into R21 and R22 based on the transitive dependency {B} -> {F} -> {G, H}: R2 = {F, G, H}, R2 = {B, F} The final set of relations in 3NF are {R11, R12, R21, R22, R3} 9. Επαναλάβετε την άσκηση 8 µε το σύνολο συναρτησιακών εξαρτήσεων G = { {A, B} {C}, {B, D} {E, F}, {A, D} {G, H}, {A} {I}, {H} {J} }. To help in solving this problem systematically, we can first find the closures of all single attributes to see if any is a key on its own as follows: {A}+ -> {A, I}, {B}+ -> {B}, {C}+ -> {C}, {D}+ -> {D}, {E}+ -> {E}, {F}+ -> {F}, {G}+ -> {G}, {H}+ -> {H, J}, {I}+ -> {I}, {J}+ -> {J} Since none of the single attributes is a key, we next calculate the closures of pairs of attributes that are possible keys: {A, B}+ -> {A, B, C, I}, {B, D}+ -> {B, D, E, F}, {A, D}+ -> {A, D, G, H, I, J} None of these pairs are keys either since none of the closures includes all attributes. But the union of the three closures includes all the attributes: {A, B, D}+ -> {A, B, C, D, E, F, G, H, I} Hence, {A, B, D} is a key. (Note: Algorithm 15.4a (see chapter 15 in the textbook) can be used to determine a key). Based on the above analysis, we decompose as follows, in a similar manner to problem 8, starting with the following relation R: R = {A, B, D, C, E, F, G, H, I} The first-level partial dependencies on the key (which violate 2NF) are: {A, B} -> {C, I}, {B, D} -> {E, F}, {A, D}+ -> {G, H, I, J} Hence, R is decomposed into R1, R2, R3, R4 (keys are underlined): R1 = {A, B, C, I}, R2 = {B, D, E, F}, R3 = {A, D, G, H, I, J}, R4 = {A, B, D} Additional partial dependencies exist in R1 and R3 because {A} -> {I}. Hence, we remove {I} into R5, so the following relations are the result of 2NF decomposition: R1 = {A, B, C}, R2 = {B, D, E, F}, R3 = {A, D, G, H, J}, R4 = {A, B, D}, R5 = {A, I} Next, we check for transitive dependencies in each of the relations (which violate 3NF). Only R3 has a transitive dependency {A, D} -> {H} -> {J}, so it is decomposed into R31 and R32 as follows: R31 = {H, J}, R32 = {A, D, G, H} The final set of 3NF relations is {R1, R2, R31, R32, R4, R5}