Shuigeng Zhou. April 6/13, 2016 School of Computer Science Fudan University
|
|
- Marilynn Austin
- 5 years ago
- Views:
Transcription
1 Lecture 6 Relational Database Design Shuigeng Zhou April 6/13, 2016 School of Computer Science Fudan University
2 Relational Database Design p First Normal Form p Pitfalls in Relational Database Design p Functional Dependencies p Decomposition p Boyce-Codd Normal Form p Third Normal Form p Multi-valued Dependencies and Fourth Normal Form p Overall Database Design Process 2
3 First Normal Form ( 第一范式 ) p Domain is atomic if its elements are considered to be indivisible units p A relational schema R is in 1NF if the domains of all attributes of R are atomic p Non-atomic values complicate storage and encourage redundant storage of data n E.g. Set of accounts stored with each customer, and set of owners stored with each account n We assume all relations are in first normal form 3
4 First Normal Form (Contd.) p Atomicity is actually a property of how the elements of the domain are used n E.g. Strings would normally be considered indivisible l Suppose that students are given roll numbers which are strings of the form n If the first two characters are extracted to find the year of enrollment, the domain of roll numbers is not atomic n Doing so is a bad idea: leads to encoding of information in application program rather than in the database 4
5 Relational Database Design p RDB design is to find a good collection of schemas. A bad design may lead to n Repetition of Information n Inability to represent certain information p Design Goals: n Avoid redundant data n Ensure that relationships among attributes are represented n Facilitate the checking of updates for violation of database integrity constraints 5
6 Example p Consider the relation schema: Lending-schema = (branch-name, branch-city, assets, customer-name, loan-number, amount) p Redundancy: n Data for branch-name, branch-city, assets are repeated for each loan that a branch makes n Wastes space n Complicates updating, introducing possibility of inconsistency of assets value p Null values n Cannot store information about a branch if no loans exist n Can use null values, but they are difficult to handle. 6
7 Decomposition p Decompose the relation schema Lending-schema into: Branch-schema = (branch-name, branch-city,assets) Loan-info-schema = (customer-name, loan-number, branch-name, amount) p All attributes of an original schema (R) must appear in the decomposition (R 1, R 2 ): R = R 1 R 2 p Lossless-join decomposition: For all possible relations r on schema R r = R1 (r) R2 (r) 7
8 Example of Non Lossless-Join Decomposition p Decomposition of R = (A, B) R 1 = (A) R 2 = (B) A B A B A (r) α α β r B (r) A B α β A (r) 1 2 B (r) α α β β
9 Goal Devise a Theory for the Following p Decide whether a particular relation R is in good form p In the case that a relation R is not in good form, decompose it into a set of relations {R 1, R 2,..., R n } such that n each relation is in good form n the decomposition is a lossless-join decomposition n the decomposition is dependency-preservation p Our theory is based on: n functional dependencies n Multi-valued dependencies 9
10 Functional Dependencies ( 函数依赖 ) p Constraints on the set of legal relations p Require that the value for a certain set of attributes determines uniquely the value for another set of attributes p A functional dependency is a generalization of the notion of a key 10
11 Functional Dependencies (Cont.) p Let R be a relation schema, α R and β R p The functional dependency α β holds on R iff for ANY legal relations r(r), whenever any two tuples t 1 and t 2 of r agree on the attributes α, they also agree on the attributes β. That is, t 1 [α]=t 2 [α] t 1 [β ]=t 2 [β ] p Example: Consider r(a,b) with the following instance of r p On this instance, A B does NOT hold, but B A does hold. 11
12 Functional Dependencies (Cont.) p K is a superkey for relation schema R iff K R p K is a candidate key for R iff n K R, and n no α K, α R p FDs allow us to express constraints that cannot be expressed using superkeys. Consider the schema: Loan-info-schema = (customer-name, loan-number, branch-name, amount). We expect this set of FDs to hold: loan-number amount loan-number branch-name but would not expect the following to hold: loan-number customer-name 12
13 Use of Functional Dependencies p We use functional dependencies to: n test relations to see if they are legal under a given set of functional dependencies. n specify constraints on the set of legal relations p Note: A specific instance of a relation schema may satisfy a functional dependency even if the functional dependency does not holds on all legal instances. n For example, a specific instance of Loan-schema may, by chance, satisfy loan-number customer-name. 13
14 Functional Dependencies (Cont.) p A functional dependency is trivial if it is satisfied by all instances of a relation n E.g. l l customer-name, loan-number customer-name customer-name customer-name n In general, α β is trivial if β α p β is fully dependent on α, if there is no proper subset α of α such that α β. Otherwise, β is partially dependent on α. 14
15 Closure of a Set of Functional Dependencies p Given a set F of FDs, there are certain other FDs that are logically implied ( 逻辑蕴涵 ) by F n E.g. If A B and B C, then we can infer that A C n The set of all FDs logically implied by F is the closure of F p We denote the closure of F by F + p We can find all of F + by applying Armstrong s Axioms n if β α, then α β (reflexivity: 自反律 ) n if α β, then γ α γ β (augmentation: 增广律 ) n if α β, and β γ, then α γ (transitivity: 传递律 ) p These rules are ( 正确且完备 ) n sound (generate only FDs that actually hold) and n complete (generate all FDs that hold) 15
16 Example p R = (A, B, C, G, H, I) F = { A B, A C, CG H, CG I, B H } p some members of F + n A H l by transitivity from A B and B H n AG I l by augmenting A C with G, to get AG CG and then transitivity with CG I n CG HI l from CG H and CG I : union rule can be inferred from definition of functional dependencies, or Augmentation of CG I to infer CG CGI, augmentation of CG H to infer CGI HI, and then transitivity 16
17 Procedure for Computing F + p To compute the closure of a set of FDs F: F + = F repeat for each FD f in F + apply reflexivity and augmentation rules on f add the resulting FDs to F + for each pair of FDs f 1 and f 2 in F + if f 1 and f 2 can be combined using transitivity then add the resulting FD to F + until F + does not change any further NOTE: We will see an alternative procedure for this task later 17
18 Closure of Functional Dependencies (Cont.) p We can further simplify manual computation of F + by using the following additional rules. n If α β holds and α γ holds, then α β γ holds (union: 合并规则 ) n If α β γ holds, then α β holds and α γ holds (decomposition: 分解规则 ) n If α β holds and γβ δ holds, then αγ δ holds (pseudotransitivity: 伪传递规则 ) The above rules can be inferred from Armstrong s axioms 18
19 Closure of Attribute Sets p Given a set of attributes α, define the closure of α under F (denoted by α + ) as the set of attributes that are functionally determined by α under F: α β is in F + β α + p Algorithm to compute α + : result := α; while (changes to result) do for each β γ in F do begin if β result then result := result γ end 19
20 Example of Attribute Set Closure p R = (A, B, C, G, H, I) p F = { A B, A C, CG H, CG I, B H } p (AG) + 1. result = AG 2. result = ABCG (A C and A B) 3. result = ABCGH (CG H and CG AGBC) 4. result = ABCGHI (CG I and CG AGBCH) p Is AG a candidate key? 1. Is AG a super key? 1. Does AG R? == Is (AG) + R 2. Is any subset of AG a superkey? 1. Does A R? == Is (A) + R 2. Does G R? == Is (G) + R 20
21 Uses of Attribute Closure There are several uses of the attribute closure: p Testing for superkey p Testing functional dependencies n To check if a functional dependency α β holds (or, in other words, is in F + ), just check if β α +. n That is, we compute α + by using attribute closure, and then check if it contains β. n Is a simple and cheap test, and very useful p Computing closure of F n For each γ R, we find the closure γ +, and for each S γ +, we output a functional dependency γ S. 21
22 Canonical Cover ( 最小覆盖 ) p Sets of FDs may have redundant FDs that can be inferred from the others n Eg: A C is redundant in: {A B, B C, A C} n Parts of a FD may be redundant l E.g. on RHS: l E.g. on LHS: {A B, B C, A CD} can be simplified to {A B, B C, A D} {A B, B C, AC D} can be simplified to {A B, B C, A D} p Intuitively, a canonical cover of F is a minimal set of FDs equivalent to F, having no redundant FDs or redundant parts of FDs 22
23 Extraneous Attributes ( 额外属性 ) p Consider a set F of FDs and the FD α β in F n Attribute A is extraneous in α if A α and F logically implies (F {α β}) {(α A) β}. n Attribute A is extraneous in β if A β and the set of FDs (F {α β}) {α (β A)} logically implies F. p Note: implication in the opposite direction is trivial in each of the cases above p Example: Given F = {A C, AB C } n B is extraneous in AB C because {A C, AB C} logically implies A C (i.e. the result of dropping B from AB C). p Example: Given F = {A C, AB CD} n C is extraneous in AB CD since AB CD can be inferred even after deleting C in AB CD 23
24 Testing if an Attribute is Extraneous p Consider a set F of FDs and α β in F. p To test if attribute A α is extraneous in α 1. compute ({α} A) + using the dependencies in F 2. check that ({α} A) + contains β; if it does, A is extraneous p To test if attribute A β is extraneous in β 1. compute α + using only the dependencies in F = (F {α β}) {α (β A)}, 2. check that α + contains A; if it does, A is extraneous 24
25 Canonical Cover p A canonical cover for F is a set of FDs F c such that n F logically implies all dependencies in F c, and n F c logically implies all dependencies in F, and n No FD in F c contains an extraneous attribute, and n Each left side of FD in F c is unique. p To compute a canonical cover for F : repeat Use the union rule to replace any dependencies in F α 1 β 1 and α 1 β 2 with α 1 β 1 β 2 Find a FD α β with an extraneous attr. either in α or in β If an extraneous attr. is found, delete it from α β until F does not change 25
26 Example of Computing a Canonical Cover p R = (A, B, C) F = {A BC, B C, A B, AB C } p Combine A BC and A B into A BC n Set is now {A BC, B C, AB C} p A is extraneous in AB C n Check if the result of deleting A from AB C is implied by the other dependencies n Set is now {A BC, B C} p C is extraneous in A BC n Check if A C is logically implied by A B and the other dependencies p The canonical cover is: {A B, B C} 26
27 Goals of Normalization p Decide whether a particular relation R is in good form p In the case that a relation R is not in good form, decompose it into a set of relations {R 1, R 2,..., R n } such that n each relation is in good form n the decomposition is a lossless-join decomposition p Our theory is based on: n functional dependencies n Multi-valued dependencies 27
28 Decomposition p Decompose the relation schema Lending-schema into: Branch-schema = (branch-name, branch-city,assets) Loan-info-schema = (customer-name, loan-number, branch-name, amount) p All attributes of an original schema (R) must appear in the decomposition (R 1, R 2 ): R = R 1 R 2 p Lossless-join decomposition. For all possible relations r on schema R r = R1 (r) R2 (r) p A decomposition of R into R 1 and R 2 is lossless join iff at least one of the following dependencies is in F + : n R 1 R 2 R 1 n R 1 R 2 R 2 28
29 Normalization Using Functional Dependencies p When we decompose a relation schema R with a set of FDs F into R 1, R 2,.., R n we want n Lossless-join decomposition: Otherwise decomposition would result in information loss. n No redundancy: The relations R i preferably should be in either BCNF or 3NF. n Dependency preservation: Let F i be the subset of dependencies F + that include only attributes in R i. l (F 1 F 2 F n ) + = F + l Otherwise, checking updates for violation of FDs may require computing joins, which is expensive. 29
30 p R = (A, B, C) F = {A B, B C) Example n Can be decomposed in two different ways p R 1 = (A, B), R 2 = (B, C) n Lossless-join decomposition: R 1 R 2 = {B} and B BC n Dependency preserving p R 1 = (A, B), R 2 = (A, C) n Lossless-join decomposition: R 1 R 2 = {A} and A AB n Not dependency preserving (cannot check B C without computing R 1 R 2 ) 30
31 Testing for Dependency Preservation p To check if α β is preserved in a decomposition of R into R 1, R 2,, R n we apply the following simplified test n result = α while (changes to result) do for each R i in the decomposition t = (result R i ) + R i result = result t (Note: here the closure is under the FD set F) n If result contains all attributes in β, then the functional dependency α β is preserved. p We apply the test on all dependencies in F to check if a decomposition is dependency preserving p This procedure takes polynomial time, instead of the exponential time required to compute F + and (F 1 F 2 F n ) + 31
32 Boyce-Codd Normal Form A relation schema R is in BCNF with respect to a set F of functional dependencies if for all functional dependencies in F + of the form α β, where α R and β R, at least one of the following holds: p α β is trivial (i.e., β α) p α is a superkey for R 32
33 p R = (A, B, C) F = {A B, B C } Key = {A} p R is not in BCNF Example p Decomposition R 1 = (A, B), R 2 = (B, C) n R 1 and R 2 in BCNF n Lossless-join decomposition n Dependency preserving 33
34 Testing for BCNF p To check if a non-trivial dependency α β causes a violation of BCNF 1. compute α + (the attribute closure of α), and 2. verify that it includes all attributes of R, that is, it is a superkey of R. p Simplified test: To check if a relation schema R is in BCNF, it suffices to check only the FDs F for violation of BCNF, rather than checking all dependencies in F +. n If none of the dependencies in F causes a violation of BCNF, then none of the dependencies in F + will cause a violation of BCNF either 34
35 Testing for BCNF (Cont.) p However, using only F is incorrect when testing a relation in a decomposition of R n E.g. Consider R (A, B, C, D), with F = {A B, B C} l Decompose R into R 1 (A,B) and R 2 (A,C,D) l Neither of the dependencies in F contain only attributes from (A,C,D) so we might be mislead into thinking R 2 satisfies BCNF. l In fact, dependency A C in F + shows R 2 is not in BCNF. 35
36 BCNF Decomposition Algorithm result := {R}; done := false; compute F + ; while (not done) do if (there is a schema R i in result that is not in BCNF) then begin let α β be a nontrivial FD that holds on R i such that α R i is not in F +, and α β = ; result := (result R i ) (R i β) (α, β ); end else done := true; Note: each R i is in BCNF, and decomposition is lossless-join. 36
37 Example Let us consider the relation scheme CTHRSG, where C=course, T=teacher, H=hour, R=room, S=student, and G=grade. The functional dependencies F we assume are: C T each course has one teacher HR C only one course can meet in a room at one time HT R a teacher can be in only one room at one time CS G each student has one grade in each course HS R a student can be in only one room at one time 37
38 Decomposition Tree CSG Key=CS CS G CTHRSG Key=HS C T CS G HR C HS R TH R CT Key=C C T CTHRS Key=HS C T HR C HS R TH R CHRS Key=HS HR C HS R CH R CHS Key=HS HS C CHR Key=CH,HR HR C CH R 38
39 Example of BCNF Decomposition p p p R = (branch-name, branch-city, assets, customer-name, loan-number, amount) F = {branch-name assets branch-city, loan-number amount branch-name} Key = {loan-number, customer-name} Decomposition n R 1 = (branch-name, branch-city, assets) n R 2 = (branch-name, customer-name, loan-number, amount) n R 3 = (branch-name, loan-number, amount) n R 4 = (customer-name, loan-number) Final decomposition R 1, R 3, R 4 39
40 Testing Decomposition for BCNF p To check if a relation R i in a decomposition of R is in BCNF, n Either test R i for BCNF w.r.t. the restriction of F to R i (that is, all FDs in F + that contain only attributes from R i ) n or use the original set of dependencies F that hold on R, but with the following test: l for every set of attributes α R i, check that α + either includes no attri. of R i - α, or includes all attributes of R i. l If the condition is violated by some α, then the FD α (α + - α ) R i can be shown to hold on R i, and R i violates BCNF. l We use above dependency to decompose R i 40
41 BCNF and Dependency Preservation It is not always possible to get a BCNF decomposition that is dependency preserving p R = (J, K, L) F = {JK L, L K} Two candidate keys = JK and JL p R is not in BCNF p Any decomposition of R will fail to preserve JK L 41
42 Third Normal Form: Motivation p There are some situations where n BCNF is not dependency preserving, and n efficient checking for FD violation on updates is important p Solution: define a weaker normal form, called Third Normal Form. n Allows some redundancy n But FDs can be checked on individual relations without computing a join n There is always a lossless-join, dependencypreservingdecomposition into 3NF 42
43 Third Normal Form p A relation schema R is in 3NF if for all: α β in F + at least one of the following holds: n α β is trivial (i.e., β α) n α is a superkey for R n Each attr. A in β α is contained in a candidate key for R. (NOTE: each attribute may be in a different candidate key) p If a relation is in BCNF it is in 3NF (since in BCNF one of the first two conditions above must hold) p Third condition is a minimal relaxation of BCNF to ensure dependency preservation 43
44 p Example n R = (J, K, L) F = {JK L, L K} 3NF (Cont.) n Two candidate keys: JK and JL n R is in 3NF JK L JK is a superkey L K K is contained in a candidate key BCNF decomposition has (JL) and (LK) l Testing for JK L requires a join p There is some redundancy in this schema p Equivalent to example in the book: Banker-schema = (branch-name, customer-name, banker-name) banker-name branch name branch name customer-name banker-name 44
45 Testing for 3NF p Optimization: Need to check only FDs in F p Use attribute closure to check for each dependency α β, if α is a superkey. p If α is not a superkey, we have to verify if each attr. in β is contained in a candidate key of R n this test is rather more expensive, since it involve finding candidate keys n testing for 3NF has been shown to be NP-hard n Interestingly, decomposition into 3NF can be done in polynomial time 45
46 3NF Decomposition Algorithm Let F c be a canonical cover for F; i := 0; for each FD α β in F c do if none of the schemas R j, 1 j i contains α, β then begin i := i + 1; R i := α β end if none of the schemas R j, 1 j i contains a candidate key for R then begin i := i + 1; R i := any candidate key for R; end return (R 1, R 2,..., R i ) 46
47 3NF Decomposition Algorithm (Cont.) pthe algorithm ensures: n each relation schema R i is in 3NF n decomposition is dependency preserving and lossless-join 47
48 p Relation schema: Example Banker-info-schema = (branch-name, customer-name, banker-name, office-number) p The FDs for this relation schema are: banker-name branch-name office-number customer-name branch-name banker-name p The key is: {customer-name, branch-name} 48
49 Applying 3NF to Banker-info-schema p The for loop in the algorithm causes us to include the following schemas in our decomposition: Banker-office-schema = (banker-name, branch-name, office-number) Banker-schema = (customer-name, branch-name, banker-name) p Since Banker-schema contains a candidate key for Banker-info-schema, we are done with the decomposition process 49
50 Comparison of BCNF and 3NF p It is always possible to decompose a relation into relations in 3NF and n the decomposition is lossless n the dependencies are preserved p It is always possible to decompose a relation into relations in BCNF and n the decomposition is lossless n it may not be possible to preserve dependencies. 50
51 Comparison of BCNF and 3NF (Cont.) p Example of problems due to redundancy in 3NF n R = (J, K, L) F = {JK L, L K} J j 1 j 2 L l 1 l 1 K k 1 k 1 j 3 null l 1 l 2 k 1 k 2 A schema that is in 3NF but not in BCNF has the problems of n repetition of information (e.g., the relationship l 1, k 1 ) n need to use null values (e.g., to represent the relationship l 2, k 2 where there is no corresponding value for J). 51
52 Design Goals p Goal for a relational database design is: n BCNF n Lossless join n Dependency preservation p If we cannot achieve this, we accept one of n Lack of dependency preservation n Redundancy due to use of 3NF 52
53 Design Goals (Cont.) p Interestingly, SQL does not provide a direct way of specifying FDs other than superkeys. Can specify FDs using assertions, but they are expensive to test p Even if we had a dependency preserving decomposition, if we use SQL we can only test efficiently these FDs whose left side is key n i.e., using SQL we would not be able to efficiently test a FD whose left hand side is not a key. 53
54 Testing for FDs Across Relations p If decomposition is not dependency preserving, we can have an extra materialized view for each dependency α β in F c that is not preserved in the decomposition p The materialized view is defined as a projection on α β of the join of the relations in the decomposition p Many newer database systems support materialized views and database system maintains the view when the relations are updated. n No extra coding effort for programmer 54
55 Testing for FDs Across Relations (Cont.) p The functional dependency α β is expressed by declaring α as a candidate key on the materialized view p Checking for candidate key cheaper than checking α β. DBMS can do candidate key check unique(α) efficiently p BUT: n Space overhead: for storing the materialized view n Time overhead: Need to keep materialized view up to date when relations are updated n Database system may not support key declarations on materialized views 55
56 Multivalued Dependencies p There are database schemas in BCNF that do not seem to be sufficiently normalized p Consider a database classes(course, teacher, book) such that (c,t,b) classes means that t is qualified to teach c, and b is a required textbook for c p The database is supposed to list for each course the set of teachers any one of which can be the course s instructor, and the set of books, all of which are required for the course 56
57 course teacher book database database database database database database operating systems operating systems operating systems operating systems Avi Avi Hank Hank Sudarshan Sudarshan Avi Avi Jim Jim classes p There are no non-trivial functional dependencies and therefore the relation is in BCNF p Insertion anomalies i.e., if Sara is a new teacher that can teach database, two tuples need to be inserted (database, Sara, DB Concepts) (database, Sara, Ullman) DB Concepts Ullman DB Concepts Ullman DB Concepts Ullman OS Concepts Shaw OS Concepts Shaw 57
58 Multivalued Dependencies (Cont.) p Therefore, it is better to decompose classes into: course database database database operating systems operating systems teacher Avi Hank Sudarshan Avi Jim course teaches book database database operating systems operating systems DB Concepts Ullman OS Concepts Shaw text We shall see that these two relations are in Fourth Normal Form (4NF) 58
59 Multivalued Dependencies (MVDs) p Let R be a relation schema and let α R and β R. The multivalued dependency α β holds on R if in any legal relation r(r), for all pairs for tuples t 1 and t 2 in r such that t 1 [α] = t 2 [α], there exist tuples t 3 and t 4 in r such that: t 1 [α] = t 2 [α] = t 3 [α] = t 4 [α] t 3 [β] = t 1 [β] t 3 [R β] = t 2 [R β] t 4 [β] = t 2 [β] t 4 [R β] = t 1 [R β] 59
60 MVD (Cont.) p Tabular representation of α β p In the above example, we have course teacher and course book 60
61 p Properties of MVD MVD (Cont.) n Symmetry: if X->->Y then X->-> Z, here Z=U-X-Y n Transitivity: if X->->Y, Y->->Z, then X->->Z-Y n If X->->Y, X->->Z, then X->->YZ n If X->->Y, X->->Z, then X->->Y Z n If X->->Y, X->->Z, then X->->Y-Z, X->->Z-Y n 61
62 Example p Let R be a relation schema with a set of attributes that are partitioned into 3 nonempty subsets. Y, Z, W p We say that Y Z (Y multi-determines Z) iff for all possible relations r(r) < y, z 1, w 1 > r and < y, z 2, w 2 > r then < y, z 1, w 2 > r and < y, z 2, w 1 > r p Note that since the behavior of Z and W are identical it follows that Y Z if Y W 62
63 p In our example: Example (Cont.) course teacher course book p The above formal definition is supposed to formalize the notion that given a particular value of Y (course) it has associated with it a set of values of Z (teacher) and a set of values of W (book), and these two sets are in some sense independent of each other p Note: n If Y Z then Y Z n Indeed we have (in above notation) Z 1 = Z 2 The claim follows. 63
64 Use of Multivalued Dependencies p We use MVDs in two ways: 1. To test relations to determine whether they are legal under a given set of FDs and MVDs 2.To specify constraints on the set of legal relations. We shall concern ourselves with relations that satisfy a given set of FDs and MVDs. p If a relation r fails to satisfy a given MVD, we can construct a relations rʹ that does satisfy the MVD by adding tuples to r 64
65 Theory of MVDs p From the definition of multivalued dependency, we can derive the following rule: n If α β, then α β; That is, every FD is also a MVD p The closure D + of D is the set of all FDs and MVDs logically implied by D. n We can compute D + from D, using the formal definitions of FDs and MVDs. n We can manage with such reasoning for very simple MVDs, which seem to be common in practice n For complex MVDs, it is better to reason about sets of dependencies using a system of inference rules (see Appendix C). 65
66 Fourth Normal Form p A relation schema R is in 4NF w.r.t. a set D of FDs and MVDs if for all MVDs in D + of the form α β, where α R and β R, at least one of the following hold: n α β is trivial (i.e., β α or α β = R) n α is a superkey for schema R p If a relation is in 4NF it is in BCNF 66
67 Restriction of Multivalued Dependencies p The restriction of D to R i is the set D i consisting of n All FDs in D + that include only attributes of R i n All MVDs of the form α (β R i ) where α R i and α β is in D + 67
68 4NF Decomposition Algorithm result: = {R}; done := false; compute D + ; Let D i denote the restriction of D + to R i while (not done) if (there is a schema R i in result that is not in 4NF) then begin let α β be a nontrivial MVD that holds on R i such that α R i is not in D i, and α β=φ; result := (result - R i ) (R i - β) (α, β); end else done:= true; Note: each R i is in 4NF, and decomposition is lossless-join 68
69 p R =(A, B, C, G, H, I) p p p Example F ={ A B B HI CG H } R is not in 4NF since A B and A is not a superkey for R Decomposition a) R 1 = (A, B) (R 1 is in 4NF) b) R 2 = (A, C, G, H, I) (R 2 is not in 4NF) c) R 3 = (C, G, H) (R 3 is in 4NF) d) R 4 = (A, C, G, I) (R 4 is not in 4NF) Since A B and B HI, A HI, A I e) R 5 = (A, I) (R 5 is in 4NF) f)r 6 = (A, C, G) (R 6 is in 4NF) 69
70 Further Normal Forms p Join dependencies generalize MVDs n lead to project-join normal form (PJNF) (also called fifth normal form) p A class of even more general constraints, leads to a normal form called domain-key normal form p Problem with these generalized constraints: are hard to reason with, and no set of sound and complete set of inference rules exists p Hence rarely used 70
71 Overall Database Design Process p We have assumed schema R is given n R could have been generated when converting E-R diagram to a set of tables. n R could have been a single relation containing all attributes that are of interest (called universal relation). n Normalization breaks R into smaller relations n R could have been the result of some ad hoc design of relations, which we then test/convert to normal form 71
72 ER Model and Normalization p When an E-R diagram is carefully designed, identifying all entities correctly, the tables generated from the E-R diagram should not need further normalization p However, in a real (imperfect) design there can be FDs from non-key attributes of an entity to other attributes of the entity p E.g. employee entity with attributes department-number and department-address, and an FD department-number department-address n Good design would have made department an entity p FDs from non-key attributes of a relationship set possible, but rare --- most relationships are binary 72
73 Universal Relation Approach p Dangling tuples Tuples that disappear in computing a join. n Let r 1 (R 1 ), r 2 (R 2 ),., r n (R n ) be a set of relations n A tuple r of the relation r i is a dangling tuple if r is not in the relation: Ri (r 1 r 2 r n ) p The relation r 1 r 2 r n is called a universal relation since it involves all the attributes in the universe defined by R 1 R 2 R n p If dangling tuples are allowed in the database, instead of decomposing a universal relation, we may prefer to synthesize a collection of normal form schemas from a given set of attributes. 73
74 Universal Relation Approach p Dangling tuples may occur in practical database applications p They represent incomplete information p E.g. may want to break up information about loans into: (branch-name, loan-number) (loan-number, amount) (loan-number, customer-name) p Universal relation would require null values, and have dangling tuples 74
75 Universal Relation Approach (Contd.) p A particular decomposition defines a restricted form of incomplete information that is acceptable in our database. n Above decomposition requires at least one of customer-name, branch-name or amount in order to enter a loan number without using null values n Rules out storing of customer-name, amount without an appropriate loan-number (since it is a key, it can't be null either!) p Universal relation requires to impose the unique role assumption, i.e., all attribute names are unique p Reuse of attribute names is natural in SQL since relation names can be prefixed to disambiguate names 75
76 Denormalization for Performance p May want to use non-normalized schema for performance p E.g. displaying customer-name along with account-number and balance requires join of account with depositor p Alternative 1: Use denormalized relation containing attributes of account as well as depositor with all above attributes n faster lookup n Extra space and extra execution time for updates n extra coding work for programmer and possibility of error in extra code p Alternative 2: use a materialized view defined as account depositor n Benefits and drawbacks same as above, except no extra coding work for programmer and avoids possible errors 76
77 Other Design Issues p Some aspects of database design are not caught by normalization p Examples of bad database design, to be avoided: Instead of earnings(company-id, year, amount), use n earnings-2000, earnings-2001, earnings-2002, etc., all on the schema (company-id, earnings). l Above are in BCNF, but make querying across years difficult and needs new table each year n company-year(company-id, earnings-2000, earnings-2001, earnings-2002) l Also in BCNF, but also makes querying across years difficult and requires new attribute each year. l Is an example of a crosstab, where values for one attribute become column names l Used in spreadsheets, and in data analysis tools 77
78 p Practice exercises n 7.1, 7.6, 7.11 p Exercises n 7.22, 7.23, 7.25, 7.27 Assignments 78
Lecture 6 Relational Database Design
Lecture 6 Relational Database Design Shuigeng Zhou October 21/27, 2009 School of Computer Science Fudan University Relational Database Design First Normal Form Pitfalls in Relational Database Design Functional
More informationChapter 7: Relational Database Design
Chapter 7: Relational Database Design Chapter 7: Relational Database Design! First Normal Form! Pitfalls in Relational Database Design! Functional Dependencies! Decomposition! Boyce-Codd Normal Form! Third
More informationChapter 7: Relational Database Design. Chapter 7: Relational Database Design
Chapter 7: Relational Database Design Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design Functional Dependencies Decomposition Boyce-Codd Normal Form Third Normal
More informationChapter 8: Relational Database Design
Chapter 8: Relational Database Design Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 8: Relational Database Design Features of Good Relational Design Atomic Domains
More informationCSE 132B Database Systems Applications
CSE 132B Database Systems Applications Alin Deutsch Database Design and Normal Forms Some slides are based or modified from originals by Sergio Lifschitz @ PUC Rio, Brazil and Victor Vianu @ CSE UCSD and
More informationDatabase System Concepts, 5th Ed.! Silberschatz, Korth and Sudarshan See for conditions on re-use "
Database System Concepts, 5th Ed.! Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-use " Features of Good Relational Design! Atomic Domains and First Normal Form! Decomposition
More informationReview: Keys. What is a Functional Dependency? Why use Functional Dependencies? Functional Dependency Properties
Review: Keys Superkey: set of attributes whose values are unique for each tuple Note: a superkey isn t necessarily minimal. For example, for any relation, the entire set of attributes is always a superkey.
More informationRelational Database Design
CSL 451 Introduction to Database Systems Relational Database Design Department of Computer Science and Engineering Indian Institute of Technology Ropar Narayanan (CK) Chatapuram Krishnan! Recap - Boyce-Codd
More informationUVA UVA UVA UVA. Database Design. Relational Database Design. Functional Dependency. Loss of Information
Relational Database Design Database Design To generate a set of relation schemas that allows - to store information without unnecessary redundancy - to retrieve desired information easily Approach - design
More informationINF1383 -Bancos de Dados
INF1383 -Bancos de Dados Prof. Sérgio Lifschitz DI PUC-Rio Eng. Computação, Sistemas de Informação e Ciência da Computação Projeto de BD e Formas Normais Alguns slides são baseados ou modificados dos originais
More informationRelational Database Design
Relational Database Design Jan Chomicki University at Buffalo Jan Chomicki () Relational database design 1 / 16 Outline 1 Functional dependencies 2 Normal forms 3 Multivalued dependencies Jan Chomicki
More informationConstraints: Functional Dependencies
Constraints: Functional Dependencies Fall 2017 School of Computer Science University of Waterloo Databases CS348 (University of Waterloo) Functional Dependencies 1 / 42 Schema Design When we get a relational
More informationFUNCTIONAL DEPENDENCY THEORY. CS121: Relational Databases Fall 2017 Lecture 19
FUNCTIONAL DEPENDENCY THEORY CS121: Relational Databases Fall 2017 Lecture 19 Last Lecture 2 Normal forms specify good schema patterns First normal form (1NF): All attributes must be atomic Easy in relational
More informationSchema Refinement: Other Dependencies and Higher Normal Forms
Schema Refinement: Other Dependencies and Higher Normal Forms Spring 2018 School of Computer Science University of Waterloo Databases CS348 (University of Waterloo) Higher Normal Forms 1 / 14 Outline 1
More informationCS322: Database Systems Normalization
CS322: Database Systems Normalization Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Introduction The normalization process takes a relation schema through
More informationRelational-Database Design
C H A P T E R 7 Relational-Database Design Exercises 7.2 Answer: A decomposition {R 1, R 2 } is a lossless-join decomposition if R 1 R 2 R 1 or R 1 R 2 R 2. Let R 1 =(A, B, C), R 2 =(A, D, E), and R 1
More informationConstraints: Functional Dependencies
Constraints: Functional Dependencies Spring 2018 School of Computer Science University of Waterloo Databases CS348 (University of Waterloo) Functional Dependencies 1 / 32 Schema Design When we get a relational
More informationSchema Refinement and Normal Forms Chapter 19
Schema Refinement and Normal Forms Chapter 19 Instructor: Vladimir Zadorozhny vladimir@sis.pitt.edu Information Science Program School of Information Sciences, University of Pittsburgh Database Management
More informationSCHEMA NORMALIZATION. CS 564- Fall 2015
SCHEMA NORMALIZATION CS 564- Fall 2015 HOW TO BUILD A DB APPLICATION Pick an application Figure out what to model (ER model) Output: ER diagram Transform the ER diagram to a relational schema Refine the
More informationCSIT5300: Advanced Database Systems
CSIT5300: Advanced Database Systems L05: Functional Dependencies Dr. Kenneth LEUNG Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong SAR, China
More informationNormalization. October 5, Chapter 19. CS445 Pacific University 1 10/05/17
Normalization October 5, 2017 Chapter 19 Pacific University 1 Description A Real Estate agent wants to track offers made on properties. Each customer has a first and last name. Each property has a size,
More informationSchema Refinement & Normalization Theory
Schema Refinement & Normalization Theory Functional Dependencies Week 13 1 What s the Problem Consider relation obtained (call it SNLRHW) Hourly_Emps(ssn, name, lot, rating, hrly_wage, hrs_worked) What
More informationDatabase Normaliza/on. Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata
Database Normaliza/on Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata Problems with redundancy Data (attributes) being present in multiple tables Potential problems Increase of storage
More informationCS54100: Database Systems
CS54100: Database Systems Keys and Dependencies 18 January 2012 Prof. Chris Clifton Functional Dependencies X A = assertion about a relation R that whenever two tuples agree on all the attributes of X,
More informationCOSC 430 Advanced Database Topics. Lecture 2: Relational Theory Haibo Zhang Computer Science, University of Otago
COSC 430 Advanced Database Topics Lecture 2: Relational Theory Haibo Zhang Computer Science, University of Otago Learning objectives and references You should be able to: define the elements of the relational
More informationFunctional Dependency Theory II. Winter Lecture 21
Functional Dependency Theory II Winter 2006-2007 Lecture 21 Last Time Introduced Third Normal Form A weakened version of BCNF that preserves more functional dependencies Allows non-trivial dependencies
More informationRelational Design: Characteristics of Well-designed DB
Relational Design: Characteristics of Well-designed DB 1. Minimal duplication Consider table newfaculty (Result of F aculty T each Course) Id Lname Off Bldg Phone Salary Numb Dept Lvl MaxSz 20000 Cotts
More informationFUNCTIONAL DEPENDENCY THEORY II. CS121: Relational Databases Fall 2018 Lecture 20
FUNCTIONAL DEPENDENCY THEORY II CS121: Relational Databases Fall 2018 Lecture 20 Canonical Cover 2 A canonical cover F c for F is a set of functional dependencies such that: F logically implies all dependencies
More informationFunctional Dependencies
Functional Dependencies Functional Dependencies Framework for systematic design and optimization of relational schemas Generalization over the notion of Keys Crucial in obtaining correct normalized schemas
More informationSchema Refinement and Normal Forms. The Evils of Redundancy. Schema Refinement. Yanlei Diao UMass Amherst April 10, 2007
Schema Refinement and Normal Forms Yanlei Diao UMass Amherst April 10, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 The Evils of Redundancy Redundancy is at the root of several problems associated
More informationDatabases 2012 Normalization
Databases 2012 Christian S. Jensen Computer Science, Aarhus University Overview Review of redundancy anomalies and decomposition Boyce-Codd Normal Form Motivation for Third Normal Form Third Normal Form
More informationSchema Refinement and Normal Forms
Schema Refinement and Normal Forms UMass Amherst Feb 14, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke, Dan Suciu 1 Relational Schema Design Conceptual Design name Product buys Person price name
More informationSchema Refinement and Normal Forms. Why schema refinement?
Schema Refinement and Normal Forms Why schema refinement? Consider relation obtained from Hourly_Emps: Hourly_Emps (sin,rating,hourly_wages,hourly_worked) Problems: Update Anomaly: Can we change the wages
More informationFunctional Dependencies and Normalization
Functional Dependencies and Normalization There are many forms of constraints on relational database schemata other than key dependencies. Undoubtedly most important is the functional dependency. A functional
More informationSchema Refinement & Normalization Theory: Functional Dependencies INFS-614 INFS614, GMU 1
Schema Refinement & Normalization Theory: Functional Dependencies INFS-614 INFS614, GMU 1 Background We started with schema design ER model translation into a relational schema Then we studied relational
More informationSchema Refinement and Normal Forms
Schema Refinement and Normal Forms Chapter 19 Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational
More informationSchema Refinement and Normal Forms. Chapter 19
Schema Refinement and Normal Forms Chapter 19 1 Review: Database Design Requirements Analysis user needs; what must the database do? Conceptual Design high level descr. (often done w/er model) Logical
More informationIntroduction. Normalization. Example. Redundancy. What problems are caused by redundancy? What are functional dependencies?
Normalization Introduction What problems are caused by redundancy? UVic C SC 370 Dr. Daniel M. German Department of Computer Science What are functional dependencies? What are normal forms? What are the
More informationSchema Refinement. Feb 4, 2010
Schema Refinement Feb 4, 2010 1 Relational Schema Design Conceptual Design name Product buys Person price name ssn ER Model Logical design Relational Schema plus Integrity Constraints Schema Refinement
More informationSchema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) CIS 330, Spring 2004 Lecture 11 March 2, 2004
Schema Refinement and Normal Forms CIS 330, Spring 2004 Lecture 11 March 2, 2004 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational schemas: redundant storage,
More informationFunctional Dependencies & Normalization. Dr. Bassam Hammo
Functional Dependencies & Normalization Dr. Bassam Hammo Redundancy and Normalisation Redundant Data Can be determined from other data in the database Leads to various problems INSERT anomalies UPDATE
More informationThe Evils of Redundancy. Schema Refinement and Normal Forms. Functional Dependencies (FDs) Example: Constraints on Entity Set. Example (Contd.
The Evils of Redundancy Schema Refinement and Normal Forms INFO 330, Fall 2006 1 Redundancy is at the root of several problems associated with relational schemas: redundant storage, insert/delete/update
More informationThe Evils of Redundancy. Schema Refinement and Normal Forms. Example: Constraints on Entity Set. Functional Dependencies (FDs) Example (Contd.
The Evils of Redundancy Schema Refinement and Normal Forms Chapter 19 Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke 1 Redundancy is at the root of several problems associated with relational
More informationThe Evils of Redundancy. Schema Refinement and Normal Forms. Example: Constraints on Entity Set. Functional Dependencies (FDs) Refining an ER Diagram
Schema Refinement and Normal Forms Chapter 19 Database Management Systems, R. Ramakrishnan and J. Gehrke 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational
More informationSchema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) [R&G] Chapter 19
Schema Refinement and Normal Forms [R&G] Chapter 19 CS432 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational schemas: redundant storage, insert/delete/update
More informationFunctional Dependencies. Applied Databases. Not all designs are equally good! An example of the bad design
Applied Databases Handout 2a. Functional Dependencies and Normal Forms 20 Oct 2008 Functional Dependencies This is the most mathematical part of the course. Functional dependencies provide an alternative
More informationSchema Refinement and Normal Forms
Schema Refinement and Normal Forms Yanlei Diao UMass Amherst April 10 & 15, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 Case Study: The Internet Shop DBDudes Inc.: a well-known database consulting
More informationThe Evils of Redundancy. Schema Refinement and Normalization. Functional Dependencies (FDs) Example: Constraints on Entity Set. Refining an ER Diagram
The Evils of Redundancy Schema Refinement and Normalization Chapter 1 Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus Redundancy is at the root of several problems
More informationFunctional Dependencies. Getting a good DB design Lisa Ball November 2012
Functional Dependencies Getting a good DB design Lisa Ball November 2012 Outline (2012) SEE NEXT SLIDE FOR ALL TOPICS (some for you to read) Normalization covered by Dr Sanchez Armstrong s Axioms other
More informationSchema Refinement. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke
Schema Refinement Yanlei Diao UMass Amherst Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 Revisit a Previous Example ssn name Lot Employees rating hourly_wages hours_worked ISA contractid Hourly_Emps
More informationDatabase Design: Normal Forms as Quality Criteria. Functional Dependencies Normal Forms Design and Normal forms
Database Design: Normal Forms as Quality Criteria Functional Dependencies Normal Forms Design and Normal forms Design Quality: Introduction Good conceptual model: - Many alternatives - Informal guidelines
More informationSchema Refinement and Normal Forms. Case Study: The Internet Shop. Redundant Storage! Yanlei Diao UMass Amherst November 1 & 6, 2007
Schema Refinement and Normal Forms Yanlei Diao UMass Amherst November 1 & 6, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 Case Study: The Internet Shop DBDudes Inc.: a well-known database consulting
More informationIntroduction to Data Management. Lecture #6 (Relational DB Design Theory)
Introduction to Data Management Lecture #6 (Relational DB Design Theory) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v Homework
More informationSchema Refinement and Normalization
Schema Refinement and Normalization Schema Refinements and FDs Redundancy is at the root of several problems associated with relational schemas. redundant storage, I/D/U anomalies Integrity constraints,
More informationCSC 261/461 Database Systems Lecture 10 (part 2) Spring 2018
CSC 261/461 Database Systems Lecture 10 (part 2) Spring 2018 Announcement Read Chapter 14 and 15 You must self-study these chapters Too huge to cover in Lectures Project 2 Part 1 due tonight Agenda 1.
More informationRelational Database Design Theory Part II. Announcements (October 12) Review. CPS 116 Introduction to Database Systems
Relational Database Design Theory Part II CPS 116 Introduction to Database Systems Announcements (October 12) 2 Midterm graded; sample solution available Please verify your grades on Blackboard Project
More informationRelational Design Theory
Relational Design Theory CSE462 Database Concepts Demian Lessa/Jan Chomicki Department of Computer Science and Engineering State University of New York, Buffalo Fall 2013 Overview How does one design a
More informationInformation Systems (Informationssysteme)
Information Systems (Informationssysteme) Jens Teubner, TU Dortmund jens.teubner@cs.tu-dortmund.de Summer 2015 c Jens Teubner Information Systems Summer 2015 1 Part VII Schema Normalization c Jens Teubner
More informationDesign Theory for Relational Databases
Design Theory for Relational Databases FUNCTIONAL DEPENDENCIES DECOMPOSITIONS NORMAL FORMS 1 Functional Dependencies X ->Y is an assertion about a relation R that whenever two tuples of R agree on all
More informationSchema Refinement and Normal Forms
Schema Refinement and Normal Forms Chapter 19 Quiz #2 Next Thursday Comp 521 Files and Databases Fall 2012 1 The Evils of Redundancy v Redundancy is at the root of several problems associated with relational
More informationFunctional Dependencies and Normalization. Instructor: Mohamed Eltabakh
Functional Dependencies and Normalization Instructor: Mohamed Eltabakh meltabakh@cs.wpi.edu 1 Goal Given a database schema, how do you judge whether or not the design is good? How do you ensure it does
More informationCS122A: Introduction to Data Management. Lecture #13: Relational DB Design Theory (II) Instructor: Chen Li
CS122A: Introduction to Data Management Lecture #13: Relational DB Design Theory (II) Instructor: Chen Li 1 Third Normal Form (3NF) v Relation R is in 3NF if it is in 2NF and it has no transitive dependencies
More informationInformation Systems for Engineers. Exercise 8. ETH Zurich, Fall Semester Hand-out Due
Information Systems for Engineers Exercise 8 ETH Zurich, Fall Semester 2017 Hand-out 24.11.2017 Due 01.12.2017 1. (Exercise 3.3.1 in [1]) For each of the following relation schemas and sets of FD s, i)
More informationIntroduction to Data Management. Lecture #6 (Relational Design Theory)
Introduction to Data Management Lecture #6 (Relational Design Theory) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v HW#2 is
More informationComp 5311 Database Management Systems. 5. Functional Dependencies Exercises
Comp 5311 Database Management Systems 5. Functional Dependencies Exercises 1 Assume the following table contains the only set of tuples that may appear in a table R. Which of the following FDs hold in
More informationDESIGN THEORY FOR RELATIONAL DATABASES. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018
DESIGN THEORY FOR RELATIONAL DATABASES csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018 1 Introduction There are always many different schemas for a given
More informationNormaliza)on and Func)onal Dependencies
Normaliza)on and Func)onal Dependencies 1NF and 2NF Redundancy and Anomalies Func)onal Dependencies A9ribute Closure Keys and Super keys 3NF BCNF Minimal Cover Algorithm 3NF Synthesis Algorithm Decomposi)on
More information10/12/10. Outline. Schema Refinements = Normal Forms. First Normal Form (1NF) Data Anomalies. Relational Schema Design
Outline Introduction to Database Systems CSE 444 Design theory: 3.1-3.4 [Old edition: 3.4-3.6] Lectures 6-7: Database Design 1 2 Schema Refinements = Normal Forms 1st Normal Form = all tables are flat
More informationLectures 6. Lecture 6: Design Theory
Lectures 6 Lecture 6: Design Theory Lecture 6 Announcements Solutions to PS1 are posted online. Grades coming soon! Project part 1 is out. Check your groups and let us know if you have any issues. We have
More informationLossless Joins, Third Normal Form
Lossless Joins, Third Normal Form FCDB 3.4 3.5 Dr. Chris Mayfield Department of Computer Science James Madison University Mar 19, 2018 Decomposition wish list 1. Eliminate redundancy and anomalies 2. Recover
More informationDatabase Design and Implementation
Database Design and Implementation CS 645 Schema Refinement First Normal Form (1NF) A schema is in 1NF if all tables are flat Student Name GPA Course Student Name GPA Alice 3.8 Bob 3.7 Carol 3.9 Alice
More informationDesign Theory for Relational Databases. Spring 2011 Instructor: Hassan Khosravi
Design Theory for Relational Databases Spring 2011 Instructor: Hassan Khosravi Chapter 3: Design Theory for Relational Database 3.1 Functional Dependencies 3.2 Rules About Functional Dependencies 3.3 Design
More informationBut RECAP. Why is losslessness important? An Instance of Relation NEWS. Suppose we decompose NEWS into: R1(S#, Sname) R2(City, Status)
So far we have seen: RECAP How to use functional dependencies to guide the design of relations How to modify/decompose relations to achieve 1NF, 2NF and 3NF relations But How do we make sure the decompositions
More informationDatabases Lecture 8. Timothy G. Griffin. Computer Laboratory University of Cambridge, UK. Databases, Lent 2009
Databases Lecture 8 Timothy G. Griffin Computer Laboratory University of Cambridge, UK Databases, Lent 2009 T. Griffin (cl.cam.ac.uk) Databases Lecture 8 DB 2009 1 / 15 Lecture 08: Multivalued Dependencies
More informationCSC 261/461 Database Systems Lecture 8. Spring 2017 MW 3:25 pm 4:40 pm January 18 May 3 Dewey 1101
CSC 261/461 Database Systems Lecture 8 Spring 2017 MW 3:25 pm 4:40 pm January 18 May 3 Dewey 1101 Agenda 1. Database Design 2. Normal forms & functional dependencies 3. Finding functional dependencies
More informationChapter 3 Design Theory for Relational Databases
1 Chapter 3 Design Theory for Relational Databases Contents Functional Dependencies Decompositions Normal Forms (BCNF, 3NF) Multivalued Dependencies (and 4NF) Reasoning About FD s + MVD s 2 Remember our
More informationChapter 10. Normalization Ext (from E&N and my editing)
Chapter 10 Normalization Ext (from E&N and my editing) Outline BCNF Multivalued Dependencies and Fourth Normal Form 2 BCNF A relation schema R is in Boyce-Codd Normal Form (BCNF) if whenever an FD X ->
More informationCAS CS 460/660 Introduction to Database Systems. Functional Dependencies and Normal Forms 1.1
CAS CS 460/660 Introduction to Database Systems Functional Dependencies and Normal Forms 1.1 Review: Database Design Requirements Analysis user needs; what must database do? Conceptual Design high level
More informationFunctional Dependency and Algorithmic Decomposition
Functional Dependency and Algorithmic Decomposition In this section we introduce some new mathematical concepts relating to functional dependency and, along the way, show their practical use in relational
More informationCSC 261/461 Database Systems Lecture 11
CSC 261/461 Database Systems Lecture 11 Fall 2017 Announcement Read the textbook! Chapter 8: Will cover later; But self-study the chapter Everything except Section 8.4 Chapter 14: Section 14.1 14.5 Chapter
More informationDesign Theory: Functional Dependencies and Normal Forms, Part I Instructor: Shel Finkelstein
Design Theory: Functional Dependencies and Normal Forms, Part I Instructor: Shel Finkelstein Reference: A First Course in Database Systems, 3 rd edition, Chapter 3 Important Notices CMPS 180 Final Exam
More informationProblem about anomalies
Problem about anomalies Title Year Genre StarName Star Wars 1977 SciFi Carrie Fisher Star Wars 1977 SciFi Harrison Ford Raiders... 1981 Action Harrison Ford Raiders... 1981 Adventure Harrison Ford When
More informationBackground: Functional Dependencies. æ We are always talking about a relation R, with a æxed schema èset of attributesè and a
Background: Functional Dependencies We are always talking about a relation R, with a xed schema èset of attributesè and a varying instance èset of tuplesè. Conventions: A;B;:::are attributes; :::;Y;Z are
More informationDECOMPOSITION & SCHEMA NORMALIZATION
DECOMPOSITION & SCHEMA NORMALIZATION CS 564- Spring 2018 ACKs: Dan Suciu, Jignesh Patel, AnHai Doan WHAT IS THIS LECTURE ABOUT? Bad schemas lead to redundancy To correct bad schemas: decompose relations
More informationCSC 261/461 Database Systems Lecture 12. Spring 2018
CSC 261/461 Database Systems Lecture 12 Spring 2018 Announcement Project 1 Milestone 2 due tonight! Read the textbook! Chapter 8: Will cover later; But self-study the chapter Chapter 14: Section 14.1 14.5
More informationCSE 344 AUGUST 6 TH LOSS AND VIEWS
CSE 344 AUGUST 6 TH LOSS AND VIEWS ADMINISTRIVIA WQ6 due tonight HW7 due Wednesday DATABASE DESIGN PROCESS Conceptual Model: name product makes company price name address Relational Model: Tables + constraints
More informationChapter 3 Design Theory for Relational Databases
1 Chapter 3 Design Theory for Relational Databases Contents Functional Dependencies Decompositions Normal Forms (BCNF, 3NF) Multivalued Dependencies (and 4NF) Reasoning About FD s + MVD s 2 Our example
More informationDesign Theory for Relational Databases
Design Theory for Relational Databases Keys: formal definition K is a superkey for relation R if K functionally determines all attributes of R K is a key for R if K is a superkey, but no proper subset
More informationData Bases Data Mining Foundations of databases: from functional dependencies to normal forms
Data Bases Data Mining Foundations of databases: from functional dependencies to normal forms Database Group http://liris.cnrs.fr/ecoquery/dokuwiki/doku.php?id=enseignement: dbdm:start March 1, 2017 Exemple
More informationIntroduction to Database Systems CSE 414. Lecture 20: Design Theory
Introduction to Database Systems CSE 414 Lecture 20: Design Theory CSE 414 - Spring 2018 1 Class Overview Unit 1: Intro Unit 2: Relational Data Models and Query Languages Unit 3: Non-relational data Unit
More informationCS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen
CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 4: DESIGN THEORIES (FUNCTIONAL DEPENDENCIES) Design theory E/R diagrams are high-level design Formal theory for
More informationCSC 261/461 Database Systems Lecture 13. Spring 2018
CSC 261/461 Database Systems Lecture 13 Spring 2018 BCNF Decomposition Algorithm BCNFDecomp(R): Find X s.t.: X + X and X + [all attributes] if (not found) then Return R let Y = X + - X, Z = (X + ) C decompose
More informationA few details using Armstrong s axioms. Supplement to Normalization Lecture Lois Delcambre
A few details using Armstrong s axioms Supplement to Normalization Lecture Lois Delcambre 1 Armstrong s Axioms with explanation and examples Reflexivity: If X Y, then X Y. (identity function is a function)
More informationDatabase Design and Normalization
Database Design and Normalization Chapter 11 (Week 12) EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 1 1NF FIRST S# Status City P# Qty S1 20 London P1 300 S1 20 London
More informationNormal Forms. Dr Paolo Guagliardo. University of Edinburgh. Fall 2016
Normal Forms Dr Paolo Guagliardo University of Edinburgh Fall 2016 Example of bad design BAD Title Director Theatre Address Time Price Inferno Ron Howard Vue Omni Centre 20:00 11.50 Inferno Ron Howard
More informationCopyright is owned by the Author of the thesis. Permission is given for a copy to be downloaded by an individual for the purpose of research and
Copyright is owned by the Author of the thesis. Permission is given for a copy to be downloaded by an individual for the purpose of research and private study only. The thesis may not be reproduced elsewhere
More informationIntroduction to Data Management. Lecture #7 (Relational DB Design Theory II)
Introduction to Data Management Lecture #7 (Relational DB Design Theory II) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v Homework
More informationFunctional Dependencies and Normalization
Functional Dependencies and Normalization 5DV119 Introduction to Database Management Umeå University Department of Computing Science Stephen J. Hegner hegner@cs.umu.se http://www.cs.umu.se/~hegner Functional
More informationRelational Design Theory I. Functional Dependencies: why? Redundancy and Anomalies I. Functional Dependencies
Relational Design Theory I Functional Dependencies Functional Dependencies: why? Design methodologies: Bottom up (e.g. binary relational model) Top-down (e.g. ER leads to this) Needed: tools for analysis
More informationCMPS Advanced Database Systems. Dr. Chengwei Lei CEECS California State University, Bakersfield
CMPS 4420 Advanced Database Systems Dr. Chengwei Lei CEECS California State University, Bakersfield CHAPTER 15 Relational Database Design Algorithms and Further Dependencies Slide 15-2 Chapter Outline
More information