Normal Forms Lossless Join.
|
|
- Gwendoline Rose
- 5 years ago
- Views:
Transcription
1 Normal Forms Lossless Join 1
2 Types of Normal Forms A relation schema R is in the first normal form (1NF) if the domain of its each attribute has only atomic values (No attribute is allowed to be composite or multi valued) Example: The following relation is not in 1NF Student (SID, SName, {(CourseId, CouseName, Grade)}) 2
3 Types of Normal Forms A relation schema R w.r.t. F is in 3NF if, for every FD X A in F, at least one of the following conditions holds: A X, that is, X A is a trivial FD, or X is a superkey, or If X is not a key, then A is part of some key of R To determine if a relation <R, F> is in 3NF: Check whether the LHS of each nontrivial FD in F is a superkey If not, check whether its RHS is part of any key of R 3
4 Types of Normal Forms A relation schema R w.r.t. F is in BCNF if, for every FD X A in F, at least one of the following conditions holds: A X, that is, X A is a trivial FD, or X is a superkey To determine whether R w.r.t. F is in BCNF Check whether the LHS X of each nontrivial FD in F is a superkey How? Simply compute X+ (w.r.t. F) and check if X+ = R 4
5 Consider R = {A, B, C, D, E, F, G} with a set of FDs F = {ABC DE, AB D, DE ABCF, E C} Is R in BCNF, 3NF, or neither? 5
6 Consider R = {A, B, C, D, E, F, G} with a set of FDs F = {ABC DE, AB D, DE ABCF, E C} Is R in BCNF, 3NF, or neither? 3NF: if, for every FD X A in F: A X, that is, X A is a trivial FD, or X is a superkey, or If X is not a key, then A is part of some key of R BCNF: For every FD X A in F: A X, that is, X A is a trivial FD, or X is a superkey 6
7 We first check if R w.r.t. F is in BCNF. Check whether the LHS X of each nontrivial FD in F is a superkey How? Simply compute X+ (w.r.t. F) and check if X+ = R Consider ABC DE ABC+ = ABCDEF R So, <R, F> is NOT in BCNF. 7
8 Is <R, F> in 3NF? We have to compute the candidate keys to determine whether <R, F> is in 3NF. 8
9 Tricks for Finding Keys using FDs F = {ABC DE, AB D, DE ABCF, E C} R = {A, B, C, D, E, F, G} If an attribute never appears on the RHS of any FD, it must be part of the key: G If an attribute never appears on the LHS of any FD, but appears on the RHS of any FD, it must not be part of any key. F We now see if G is itself a key: G+= G R; So, G alone is not key. 9
10 F = {ABC DE, AB D, DE ABCF, E C} R = {A, B, C, D, E, F, G} Now we try to find keys by adding more attributes (except F) to G Add LHS of FDs that have only one attribute (E in E C) GE+ = GEC R Add LHS of FDs that have two attributes (AB in AB D & DE in DE ABCF) GAB+ = GABD GDE+ = ABCDEFG = R; It s a key! Add LHS of FDs that have three attributes (ABC in ABC DE), but not taking super set of GDE: GABC+ = ABCDEFG = R; [ABC DE, DE ABCF] It s a key! GABE+ = ABCDEFG = R; [AB D, DE ABCF] It s a key! If we add any further attribute(s), they will form the superkey. Therefore, we can stop here. The candidate key(s) are {GDE, GABC, GABE} 10
11 Consider R = {A, B, C, D, E, F, G} with a set of FDs F = {ABC DE, AB D, DE ABCF, E C} Is R in 3NF? The candidate key(s) are {GDE, GABC, GABE} 3NF: if, for every FD X A in F: A X, that is, X A is a trivial FD, or X is a superkey, or If X is not a key, then A is part of some key of R 11
12 <R, F> is not in 3NF because: No FD is trivial. LHS of all FDs are not superkey. There is FD whose RHS is not a part of key (DE ABCF). So, <R, F> is NOT in 3NF either! 12
13 Binary Decomposition Binary Decomposition can be applied to: Decompose a non-bcnf relation into a collection of BCNF relations. Decompose a non-3nf relation into a collection of 3NF relations. 13
14 Basic Steps of Binary Decomposition Suppose X A F is a FD violating the BCNF (resp. 3NF) requirement, where X R and A R. Decompose R into XA and R A. R X A If either XA or R A is not in BCNF (resp. 3NF), decompose it further. XA R A 14
15 Binary Decomposition If R w.r.t. F is not in BCNF, we can always obtain a lossless-join decomposition of R into a collection of BCNF relations. However, it may not always be dependency preserving If R w.r.t. F is not in 3NF, we can always obtain a lossless-join decomposition and dependency preserving of R into a collection of 3NF relations. How? For each FD X A in Lost, create a relation schema XA and add it to R Refinement step: if there are several FD s with the same LHS, e.g., X A1, X A2,..., X Ak, we replace these k FD s with a single FD, X A1 Ak, and create just one relation with schema XA1 Ak. 15
16 Synthesis Approach (applicable for 3NF) Consider relation schema <R, F>, Get a canonical cover C of F For each FD X A in C, add schema XA to R If the decomposition R is not lossless, need to fix it by adding to R an extra relation schema containing just those attributes that form any key of R. 16
17 Review: Decomposition into 3NF Binary Decomposition Lossless-join May not be dependency preserving. If so, then add extra relations XA, one for each FD X A we lost Synthesis Approach Dependency preservation May not be lossless-join. If so, we need to add to R one extra relation schema that includes the attributes that form any key of R 17
18 Consider R = {A, B, C, D, E, F, G, H} with a set of FDs F = {CD A, EC H, GHB AB, C D, EG A, H B, BE CD, EC B} The candidate keys are: {BEFG, CEFG, EFGH} Is R w.r.t. F in 3NF? If not, decompose it into relations in 3NF using: 1. Binary Decomposition 2. Synthesis Approach 18
19 The candidate keys are: {BEFG, CEFG, EFGH} No, R w.r.t. F is NOT in 3NF, because CD A violates the 3NF requirements, i.e. CD A is not trivial FD CD is not a superkey CD is not a key, but A is not part of any key of R either 19
20 1. Binary Decomposition Approach Considering R, Keys ={BEFG, CEFG, EFGH}, F = {CD A, EC H, GHB AB, C D, EG A, H B, BE CD, EC B} Decomposition #1: CD A is a violating FD R is decomposed into R1 and R2: R1 (A,C,D): We need to project FDs F onto relation R1: A+ = A C+ = CDA (C DA) D+ = D AC+ = ACD (AC D) AD+ = AD CD+ = CDA (CD A) So, F1 = {C DA, AC D, CD A} R2 ( B,C,D,E,F,G,H): We need to project FDs F onto relation R2 Note that the only difference between R and R2 is attribute A. Attribute A has never appeared on LHS of any FD. So, removing it won t make any change in F2. So, F2={EC H, GHB B, C D, H B, BE CD, EC B} FDs that are lost in Decomposition #1 are {GHB A, EG A} 20
21 1. Binary Decomposition Approach Decomposition #1: R is decomposed into R1 and R2: R1 (A,C,D): F1 = {C DA, AC D, CD A} R2 ( B,C,D,E,F,G,H): F2={EC H, C D, H B, BE CD, EC B} Do we need further decomposition? 21
22 1. Binary Decomposition Approach Decomposition #1: R1 (A,C,D): F1 = {C DA, AC D, CD A} Since C+=ACD, C is a key. C (in C DA), CD (in CD A), and AC (in AC D) are key/super keys. Therefore, we have no violating FD. (So, we are done with this branch.) 22
23 1. Binary Decomposition Approach Decomposition #1: R2 ( B,C,D,E,F,G,H): F2={EC H, C D, H B, BE CD, EC B} Keys of R2 = Keys of R = {BEFG, CEFG, EFGH} EC H is not a violating FD, since H is part of a key. C D is a violating FD, since C is not a super key and D is not part of any key. So, further decomposition is needed. 23
24 1. Binary Decomposition Approach R2 ( B,C,D,E,F,G,H) F2={EC H, C D, H B, BE CD, EC B} Decomposition #2: C D is a violating FD R2 is decomposed into R21 and R22: R21 (C,D): We need to project FDs F2 onto relation R21: C+=CD D+=D So, F21={C D} R22 ( B,C,E,F,G,H): In general, we should project F2 onto R22. However, if we look carefully, we can easily see that the only difference between R2 and R22 is attribute D. Attribute D has never appeared on LHS of any FD. So, removing it won t make any change in F22. So, F22 = {EC H, H B, BE C, EC B} FDs that are lost in Decomposition #2 is {BE D} So, overall, we ve lost the following FDs: {GHB A, EG A, BE D} 24
25 1. Binary Decomposition Approach Decomposition #2: R21 (C,D): F21={C D} R22 ( B,C,E,F,G,H): F22 = {EC H, H B, BE C, EC B} Do we need further decomposition? 25
26 1. Binary Decomposition Approach Decomposition #2: R21 (C,D): F21={C D} Since C+=CD, C is a key. Therefore, we have no violating FD. (So, we are done with this branch.) R22 ( B,C,E,F,G,H): F22 = {EC H, H B, BE C, EC B} EC H is not a violating FD since H is part of a key. H B is not a violating FD since B is part of a key. BE C is not a violating FD since C is part of a key. EC B is not a violating FD since B is part of a key. So, we are done with this branch. 26
27 1. Binary Decomposition Approach Overall, we have: R1 (A, C, D) F1 = {C DA, AC D, CD A} R21 (C, D) F21 = {C D} R22 (B, C, E, F, G, H) F22 = {EC H, H B, BE C, EC B} Since R1 includes R21 we might want to remove R21. This is a loss-less join decomposition, but it is not dependency preserving. To make the decomposition dependency preserving, we need to add the lost FDs as new relations. The lost FDs are: {GHB AB, EG A, BE D} So, we add three relations: L1(A, B, G, H) FL1 = {GHB AB} L2(A, E, G) FL2 = {EG A} L3(B, D, E) FL3 = {BE D} 27
28 2. Synthesis Approach R = {A, B, C, D, E, F, G, H} with a set of FDs F = {CD A, EC H, GHB AB, C D, EG A, H B, BE CD, EC B} The candidate keys are {BEFG, CEFG, EFGH} In the last tutorial, we found that the canonical cover for F is: C= {C AD, EC H, GH A, EG A, H B, BE C} 28
29 2. Synthesis Approach C= {C AD, EC H, GH A, EG A, H B, BE C} Now, we create the relations: R1 = {A, C, D} F1 = {C AD} R2 = {E, C, H} F2 = {EC H} R3 = {A, G, H} F3 = {GH A} R4 = {A, E, G} F4 = {EG A} R5 = {B, H} F5 = {H B} R6 = {B, C, E} F6 = {BE C} Now, we need to check if at least one of the keys exists in the above relations. The candidate keys are {BEFG, CEFG, EFGH} Since none of these keys is in the relations, this decomposition is not lossless. So, we need to add an extra relation containing those attributes that form any key of R: R7 = {B, E, F, G} F7 = {} 29
30 Assume R(A, B, C, D, E, F, G) with the set of FDs F={C AD, E G, FG A, EF A, G B, BE C} is decomposed into the following relations. Check if this decomposition is lossless join. R1 = {A, C, D} R2 = {E, C, G} R3 = {A, F, G} R4 = {A, E, F} R5 = {B, G} R6 = {B, C, E} 30
31 Step1-Table Initialization A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} b2a b2b a b2d a b2f a R3 = {A, F, G} a b3b b3c b3d b3e a a R4 = {A, E, F} a b4b b4c b4d a a b4g R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} b6a a a b6d a b6f b6g 31
32 Round1: Consider C AD A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} b2a b2b a b2d a b2f a R3 = {A, F, G} a b3b b3c b3d b3e a a R4 = {A, E, F} a b4b b4c b4d a a b4g R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} b6a a a b6d a b6f b6g 32
33 Round1: Consider C AD A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a b2b a a a b2f a R3 = {A, F, G} a b3b b3c b3d b3e a a R4 = {A, E, F} a b4b b4c b4d a a b4g R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f b6g 33
34 Round1: Consider E G A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a b2b a a a b2f a R3 = {A, F, G} a b3b b3c b3d b3e a a R4 = {A, E, F} a b4b b4c b4d a a b4g R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f b6g 34
35 Round1: Consider E G A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a b2b a a a b2f a R3 = {A, F, G} a b3b b3c b3d b3e a a R4 = {A, E, F} a b4b b4c b4d a a a R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f a 35
36 Round1: Consider FG A A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a b2b a a a b2f a R3 = {A, F, G} a b3b b3c b3d b3e a a R4 = {A, E, F} a b4b b4c b4d a a a R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f a 36
37 Round1: Consider EF A A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a b2b a a a b2f a R3 = {A, F, G} a b3b b3c b3d b3e a a R4 = {A, E, F} a b4b b4c b4d a a a R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f a 37
38 Round1: Consider G B A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a b2b a a a b2f a R3 = {A, F, G} a b3b b3c b3d b3e a a R4 = {A, E, F} a b4b b4c b4d a a a R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f a 38
39 Round1: Consider G B A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a a a a a b2f a R3 = {A, F, G} a a b3c b3d b3e a a R4 = {A, E, F} a a b4c b4d a a a R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f a 39
40 Round1: Consider BE C A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a a a a a b2f a R3 = {A, F, G} a a b3c b3d b3e a a R4 = {A, E, F} a a b4c b4d a a a R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f a 40
41 Round1: Consider BE C A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a a a a a b2f a R3 = {A, F, G} a a b3c b3d b3e a a R4 = {A, E, F} a a a b4d a a a R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f a 41
42 Round2: Consider C AD A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a a a a a b2f a R3 = {A, F, G} a a b3c b3d b3e a a R4 = {A, E, F} a a a b4d a a a R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f a 42
43 Round2: Consider C AD A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a a a a a b2f a R3 = {A, F, G} a a b3c b3d b3e a a R4 = {A, E, F} a a a a a a a R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f a 43
44 We don t need to continue since we found one row in the table with all cells having a. So, this is a lossless join. A B C D E F G R1 = {A, C, D} a b1b a a b1e b1f b1g R2 = {E, C, G} a a a a a b2f a R3 = {A, F, G} a a b3c b3d b3e a a R4 = {A, E, F} a a a a a a a R5 = {B, G} b5a a b5c b5d b5d b5f a R6 = {B, C, E} a a a a a b6f a 44
45 Dependency-Preserving Checking Let R,F, where F = {X1 Y1,, Xn Yn}. Let R ={ R1,,Rk} be a decomposition of R and Fi be the projection of F on R preserved TRUE for each FD X Y in F and while preserved == TRUE do begin compute X+ under F1... Fn; if Y X+ then {preserved FALSE; Exit }; end 45
46 Example Consider R = ( A, B, C, D ), F = { A B, B C, C D }. Is the decomposition R = {R1, R2} dependency-preserving, where R1= ( A, B ), F1 = { A B}, R2= ( A, C, D), and F2 = { C D, A D, A C }? Check if A B is preserved: Compute A+ under F1 F2={ A B} { C D, A D, A C} A+ = { A, B, D } Check if B A+ Yes, A B is preserved Check if B C is preserved Compute B+ under F1 F2={ { A B} { C D, A D, A C} B+ = { B } Check if C B+ No, B C is not preserved The decomposition is not dependency-preserving 46
47 47
1. Binary Decomposition Approach: Considering R: Keys ={BEFG, CEFG, EFGH} F = {CD A, EC H, GHB AB, C D, EG A, H B, BE CD, EC B}
Question 1: Consider R = {A, B, C, D, E, F, G, H} with set of FDs F = {CD A, EC H, GHB AB, C D, EG A, H B, BE CD, EC B} The cndidte keys re: {BEFG, CEFG, EFGH} Is R w.r.t. F in 3NF? If not decompose it
More informationConsider a relation R with attributes ABCDEF GH and functional dependencies S:
University of Toronto CSC343 Sample 3NF Problem Questions Consider a relation R with attributes ABCDEF GH and functional dependencies S: S = {A CD, ACF G, AD BEF, BCG D, CF AH, CH G, D B, H DEG} 1. Compute
More informationConsider a relation R with attributes ABCDEF GH and functional dependencies S:
University of Toronto CSC343 Sample 3NF Problem Questions Consider a relation R with attributes ABCDEF GH and functional dependencies S: 1. Compute all keys for R. S = {A CD, ACF G, AD BEF, BCG D, CF AH,
More informationNormal Forms (ii) ICS 321 Fall Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa
ICS 321 Fall 2012 Normal Forms (ii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 9/12/2012 Lipyeow Lim -- University of Hawaii at Manoa 1 Hourly_Emps
More informationDesign theory for relational databases
Design theory for relational databases 1. Consider a relation with schema R(A,B,C,D) and FD s AB C, C D and D A. a. What are all the nontrivial FD s that follow from the given FD s? You should restrict
More informationChapter 11, Relational Database Design Algorithms and Further Dependencies
Chapter 11, Relational Database Design Algorithms and Further Dependencies Normal forms are insufficient on their own as a criteria for a good relational database schema design. The relations in a database
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 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 informationRelational Design Theory II. Detecting Anomalies. Normal Forms. Normalization
Relational Design Theory II Normalization Detecting Anomalies SID Activity Fee Tax 1001 Piano $20 $2.00 1090 Swimming $15 $1.50 1001 Swimming $15 $1.50 Why is this bad design? Can we capture this using
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 informationFunctional Dependencies
Functional Dependencies P.J. M c.brien Imperial College London P.J. M c.brien (Imperial College London) Functional Dependencies 1 / 41 Problems in Schemas What is wrong with this schema? bank data no sortcode
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 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 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 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 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 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 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 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 informationCS 186, Fall 2002, Lecture 6 R&G Chapter 15
Schema Refinement and Normalization CS 186, Fall 2002, Lecture 6 R&G Chapter 15 Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus Functional Dependencies (Review)
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 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 informationHomework 2 (by Prashasthi Prabhakar) Due: Wednesday Sep 20, 11:59pm
CARNEGIE MELLON UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE 15-445/645 DATABASE SYSTEMS (FALL 2017) PROF. ANDY PAVLO Homework 2 (by Prashasthi Prabhakar) Due: Wednesday Sep 20, 2017 @ 11:59pm IMPORTANT:
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 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 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 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 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 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 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 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 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 informationHomework 2 (by Prashasthi Prabhakar) Solutions Due: Wednesday Sep 20, 11:59pm
CARNEGIE MELLON UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE 15-445/645 DATABASE SYSTEMS (FALL 2017) PROF. ANDY PAVLO Homework 2 (by Prashasthi Prabhakar) Solutions Due: Wednesday Sep 20, 2017 @ 11:59pm IMPORTANT:
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 informationHKBU: Tutorial 4
COMP7640 @ HKBU: Tutorial 4 Functional Dependency and Database Normalization Wei Wang weiw AT cse.unsw.edu.au School of Computer Science & Engineering University of New South Wales October 17, 2014 Wei
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 informationRelational Database Design
Relational Database Design Chapter 15 in 6 th Edition 2018/4/6 1 10 Relational Database Design Anomalies can be removed from relation designs by decomposing them until they are in a normal form. Several
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 information12/3/2010 REVIEW ALGEBRA. Exam Su 3:30PM - 6:30PM 2010/12/12 Room C9000
REVIEW Exam Su 3:30PM - 6:30PM 2010/12/12 Room C9000 2 ALGEBRA 1 RELATIONAL ALGEBRA OPERATIONS Basic operations Selection ( ) Selects a subset of rows from relation. Projection ( ) Deletes unwanted columns
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 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 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 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 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 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 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 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: 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 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 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 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 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 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 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 & 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 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 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 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 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 informationCS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #15: BCNF, 3NF and Normaliza:on
CS 4604: Introduc0on to Database Management Systems B. Aditya Prakash Lecture #15: BCNF, 3NF and Normaliza:on Overview - detailed DB design and normaliza:on pi?alls of bad design decomposi:on normal forms
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 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 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 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 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 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 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 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 informationPractice and Applications of Data Management CMPSCI 345. Lecture 16: Schema Design and Normalization
Practice and Applications of Data Management CMPSCI 345 Lecture 16: Schema Design and Normalization Keys } A superkey is a set of a/ributes A 1,..., A n s.t. for any other a/ribute B, we have A 1,...,
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 informationExam 1 Solutions Spring 2016
Exam 1 Solutions Spring 2016 Problem 1 1. R 1 := σ color= red OR color= green (P arts) Result := Π sid (R 1 Catalog) 2. R 1 := σ sname= Y osemitesham (Suppliers) R 2 := Π pid,cost (R 1 Catalog) R 3 (pid1,
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 informationKapitel 3: Formal Design
Theory I: Database Foundations 3. Formal Design 3. Kapitel 3: Formal Design We want to distinguish good from bad database design. What kind of additional information do we need? Can we transform a bad
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 informationNormal Forms 1. ICS 321 Fall Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa
ICS 321 Fall 2013 Normal Forms 1 Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 9/16/2013 Lipyeow Lim -- University of Hawaii at Manoa 1 The Problem with
More informationL14: Normalization. CS3200 Database design (sp18 s2) 3/1/2018
L14: Normalization CS3200 Database design (sp18 s2) https://course.ccs.neu.edu/cs3200sp18s2/ 3/1/2018 367 Announcements! Keep bringing your name plates J Outline today - More Normalization - Project 1
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 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. 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 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 informationzone# Garbage_Truck ships_to Garbage_Structure structid max_age
B561 Assignment 2 Solutions C.M. Wyss September 19, 2001 1. Questions a-c (below) concern the ER diagram in gure 1 (below). truckid driver zone# Garbage_Truck services Zone ships_to structid Garbage_Structure
More information