Database Design and Normal Forms
|
|
|
- Godfrey White
- 10 years ago
- Views:
Transcription
1 Database Design and Normal Forms Database Design coming up with a good schema is very important How do we characterize the goodness of a schema? If two or more alternative schemas are available how do we compare them? What are the problems with bad schema designs? Normal Forms: Each normal form specifies certain conditions If the conditions are satisfied by the schema certain kind of problems are avoided Details follow. 1
2 An Example student relation with attributes: studname, rollno, sex, studdept department relation with attributes: deptname, officephone, hod Several students belong to a department. studdept gives the name of the student s department. Correct schema: Student Department studname rollno sex studdept deptname officephone HOD Incorrect schema: Student Dept studname rollno sex deptname officephone HOD What are the problems that arise? 2
3 Problems with bad schema Redundant storage of data: Office Phone & HOD info - stored redundantly once with each student that belongs to the department wastage of disk space A program that updates Office Phone of a department must change it at several places more running time error - prone Transactions running on a database must take as short time as possible to increase transaction throughput 3
4 Update Anomalies Another kind of problem with bad schema Insertion anomaly: No way of inserting info about a new department unless we also enter details of a (dummy) student in the department Deletion anomaly: If all students of a certain department leave and we delete their tuples, information about the department itself is lost Update Anomaly: Updating officephone of a department value in several tuples needs to be changed if a tuple is missed - inconsistency in data 4
5 Normal Forms First Normal Form (1NF) - included in the definition of a relation Second Normal Form (2NF) defined in terms of Third Normal Form (3NF) functional dependencies Boyce-Codd Normal Form (BCNF) Fourth Normal Form (4NF) - defined using multivalued dependencies Fifth Normal Form (5NF) or Project Join Normal Form (PJNF) defined using join dependencies 5
6 Functional Dependencies A functional dependency (FD) X Y (read as X determines Y) (X R, Y R) is said to hold on a schema R if in any instance r on R, if two tuples t 1, t 2 (t 1 t 2, t 1 r, t 2 r) agree on X i.e. t 1 [X] = t 2 [X] then they also agree on Y i.e. t 1 [Y] = t 2 [Y] Note: If K R is a key for R then for any A R, K A holds because the above if..then condition is vacuously true 6
7 Functional Dependencies Examples Consider the schema: Student ( studname, rollno, sex, dept, hostelname, roomno) Since rollno is a key, rollno {studname, sex, dept, hostelname, roomno} Suppose that each student is given a hostel room exclusively, then hostelname, roomno rollno Suppose boys and girls are accommodated in separate hostels, then hostelname sex FDs are additional constraints that can be specified by designers 7
8 Trivial / Non-Trivial FDs An FD X Y where Y X -called a trivial FD, it always holds good An FD X Y where Y X - non-trivial FD An FD X Y where X Y = f - completely non-trivial FD 8
9 Deriving new FDs Given that a set of FDs F holds on R we can infer that a certain new FD must also hold on R For instance, given that X Y, Y Z hold on R we can infer that X Z must also hold How to systematically obtain all such new FDs? Unless all FDs are known, a relation schema is not fully specified 9
10 Entailment relation We say that a set of FDs F { X Y} (read as F entails X Y or F logically implies X Y) if in every instance r of R on which FDs F hold, FD X Y also holds. Armstrong came up with several inference rules for deriving new FDs from a given set of FDs We define F + = {X Y F X Y} F + : Closure of F 10
11 Armstrong s Inference Rules (1/2) 1. Reflexive rule F {X Y Y X} for any X. Trivial FDs 2. Augmentation rule {X Y} {XZ YZ}, Z R. Here XZ denotes X Z 3. Transitive rule {X Y, Y Z} {X Z} 4. Decomposition or Projective rule {X YZ} {X Y} 5. Union or Additive rule {X Y, X Z} {X YZ} 6. Pseudo transitive rule {X Y, WY Z} {WX Z} 11
12 Armstrong's Inference Rules (2/2) Rules 4, 5, 6 are not really necessary. For instance, Rule 5: {X Y, X Z} {X YZ} can be 1) X Y 2) X Z given 3) X XY Augmentation rule on 1 4) XY ZY Augmentation rule on 2 5) X ZY Transitive rule on 3, 4. Similarly, 4, 6 can be shown to be unnecessary. But it is useful to have 4, 5, 6 as short-cut rules proved using 1, 2, 3 alone 12
13 Sound and Complete Inference Rules Armstrong showed that Rules (1), (2) and (3) are sound and complete. These are called Armstrong s Axioms (AA) Soundness: Every new FD X Y derived from a given set of FDs F using Armstrong's Axioms is such that F {X Y} Completeness: Any FD X Y logically implied by F (i.e. F {X Y}) can be derived from F using Armstrong s Axioms 13
14 Proving Soundness Suppose X Y is derived from F using AA in some n steps. If each step is correct then overall deduction would be correct. Single step: Apply Rule (1) or (2) or (3) Rule (1) obviously results in correct FDs Rule (2) {X Y} {XZ YZ}, Z R Suppose t 1, t 2 r agree on XZ t 1, t 2 agree on X t 1, t 2 agree on Y (since X Y holds on r) t 1, t 2 agree as YZ Hence Rule (2) gives rise to correct FDs Rule (3) {X Y, Y Z} X Z Suppose t 1, t 2 r agree on X t 1, t 2 agree on Y (since X Y holds) t 1, t 2 agree on Z (since Y Z holds) 14
15 Proving Completeness of Armstrong s Axioms (1/4) Define X + F (closure of X wrt F) = {A X A can be derived from F using AA}, A R Claim1: X Y can be derived from F using AA iff Y X + (If) Let Y = {A 1, A 2,, A n }. Y X + X A i can be derived from F using AA (1 i n) By union rule, it follows that X Y can be derived from F. (Only If) X Y can be derived from F using AA By projective rule X A i (1 i n) Thus by definition of X +, A i X + Y X + 15
16 Completeness of Armstrong s Axioms (2/4) Completeness: (F {X Y}) X Y follows from F using AA We will prove the contrapositive: X Y can t be derived from F using AA F {X Y} a relation instance r on R st all the FDs of F hold on r but X Y doesn t hold. Consider the relation instance r with just two tuples: X + attributes Other attributes r:
17 Completeness Proof (3/4) Claim 2: All FDs of F are satisfied by r Suppose not. Let W Z in F be an FD not satisfied by r Then W X + and Z X + Let A Z X + Now, X W follows from F using AA as W X + (claim 1) X Z follows from F using AA by transitive rule Z A follows from F using AA by reflexive rule as A Z X A follows from F using AA by transitive rule By definition of closures, A must belong to X + - a contradiction. r: Hence the claim X + R - X + 17
18 Completeness Proof (4/4) Claim 3: X Y is not satisfied by r Suppose not Because of the structure of r, Y X + X Y can be derived from F using AA contradicting the assumption about X Y Hence the claim Thus, whenever X Y doesn t follow from F using AA, F doesn t logically imply X Y Armstrong s Axioms are complete. 18
19 Consequence of Completeness of AA X + = {A X A follows from F using AA} = {A F X A} Similarly F + = {X Y F X Y} = {X Y X Y follows from F using AA} 19
20 Computing closures The size of F + can sometimes be exponential in the size of F. For instance, F = {A B 1, A B 2,.., A B n } F + = {A X} where X {B 1, B 2,,B n }. Thus F + = 2 n Computing F + : computationally expensive Fortunately, checking if X Y F + can be done by checking if Y X + F Computing attribute closure (X + F ) is easier 20
21 Computing X + F We compute a sequence of sets X 0, X 1, as follows: X 0 := X; // X is the given set of attributes X i+1 := X i {A there is a FD Y Z in F and A Z and Y X i } Since X 0 X 1 X 2... X i X i+1... R and R is finite, There is an integer i st X i = X i+1 = X i+2 = and X + F is equal to X i. 21
22 Normal Forms 2NF Full functional dependency: An FD X A for which there is no proper subset Y of X such that Y A (A is said to be fully functionally dependent on X) 2NF: A relation schema R is in 2NF if every non-prime attribute is fully functionally dependent on any key of R prime attribute: A attribute that is part of some key non-prime attribute: An attribute that is not part of any key 22
23 Example 1) Book (authorname, title, authoraffiliation, ISBN, publisher, pubyear ) Keys: (authorname, title), ISBN Not in 2NF as authorname Æ authoraffiliation (authoraffiliation is not fully functionally dependent on the first key) 2) Student (rollno, name, dept, sex, hostelname, roomno, admityear) Keys: rollno, (hostelname, roomno) Not in 2NF as hostelname sex student (rollno, name, dept, hostelname, roomno, admityear) hosteldetail (hostelname, sex) - There are both in 2NF 23
24 Transitive Dependencies Transitive dependency: An FD X Y in a relation schema R for which there is a set of attributes Z R such that X Z and Z Y and Z is not a subset of any key of R Ex: student (rollno, name, dept, hostelname, roomno, headdept) Keys: rollno, (hostelname, roomno) rollno dept; dept headdept hold So, rollno headdept a transitive dependency Head of the dept of dept D is stored redundantly in every tuple where D appears. Relation is in 2NF but redundancy still exists. 24
25 Normal Forms 3NF Relation schema R is in 3NF if it is in 2NF and no non-prime attribute of R is transitively dependent on any key of R student (rollno, name, dept, hostelname, roomno, headdept) is not in 3NF Decompose: student (rollno, name, dept, hostelname, roomno) deptinfo (dept, headdept) both in 3NF Redundancy in data storage - removed 25
26 Another definition of 3NF Relation schema R is in 3NF if for any nontrivial FD X A either (i) X is a superkey or (ii) A is prime. Suppose some R violates the above definition There is an FD X A for which both (i) and (ii) are false X is not a superkey and A is non-prime attribute Two cases arise: 1) X is contained in a key A is not fully functionally dependent on this key - violation of 2NF condition 2) X is not contained in a key K X, X A is a case of transitive dependency (K any key of R) 26
27 Motivating example for BCNF gradeinfo (rollno, studname, course, grade) Suppose the following FDs hold: 1) rollno, course grade Keys: 2) studname, course grade (rollno, course) 3) rollno studname (studname, course) 4) studname rollno For 1,2 lhs is a key. For 3,4 rhs is prime So gradeinfo is in 3NF But studname is stored redundantly along with every course being done by the student 27
28 Boyce - Codd Normal Form (BCNF) Relation schema R is in BCNF if for every nontrivial FD X A, X is a superkey of R. In gradeinfo, FDs 3, 4 are nontrivial but lhs is not a superkey So, gradeinfo is not in BCNF Decompose: gradeinfo (rollno, course, grade) studinfo (rollno, studname) Redundancy allowed by 3NF is disallowed by BCNF BCNF is stricter than 3NF 3NF is stricter than 2NF 28
29 Decomposition of a relation schema If R doesn t satisfy a particular normal form, we decompose R into smaller schemas What s a decomposition? R = (A 1, A 2,, A n ) D = (R 1, R 2,, R k ) st R i R and R = R 1 R 2 R k (R i s need not be disjoint) Replacing R by R 1, R 2,, R k process of decomposing R Ex: gradeinfo (rollno, studname, course, grade) R 1 : gradeinfo (rollno, course, grade) R 2 : studinfo (rollno, studname) 29
30 Desirable Properties of Decompositions Not all decomposition of a schema are useful We require two properties to be satisfied (i) Lossless join property - the information in an instance r of R must be preserved in the instances r 1, r 2,,r k where r i = p Ri (r) (ii) Dependency preserving property - if a set F of dependencies hold on R it should be possible to enforce F by enforcing appropriate dependencies on each r i 30
31 Lossless join property F set of FDs that hold on R R decomposed into R 1, R 2,,R k Decomposition is lossless wrt F if for every relation instance r on R satisfying F, r = p R1 (r) * p R2 (r) * * p Rk (r) R = (A, B, C); R 1 = (A, B); R 2 = (B, C) Lossless joins are also called non-additive joins Original info is distorted r: A B C r 1 : A B r 2 : B C r 1 * r 2 : A B C a 1 b 1 c 1 a 1 b 1 b 1 c 1 a 1 b 1 c 1 a 2 b 2 c 2 a 2 b 2 b 2 c 2 a 1 b 1 c 3 a 3 b 1 c 3 a 3 b 1 b 1 c 3 a 2 b 2 c 2 Lossy join Spurious tuples a 3 b 1 c 1 a 3 b 1 c 3 31
32 Dependency Preserving Decompositions Decomposition D = (R 1, R 2,,R k ) of schema R preserves a set of dependencies F if (p R1 (F) p R2 (F) p Rk (F)) + = F + Here, p Ri (F) = { (X Æ Y) F + X R i, Y R i } (called projection of F onto R i ) Informally, any FD that logically follows from F must also logically follow from the union of projections of F onto R i s Then, D is called dependency preserving. 32
33 An example Schema R = (A, B, C) FDs F = {A B, B C, C A} Decomposition D = (R 1 = {A, B}, R 2 = {B, C}) p R1 (F) = {A B, B A} p R2 (F) = {B C, C B} (p R1 (F) p R2 (F)) + = {A B, B A, B C, C B, A C, C A} = F + Hence Dependency preserving 33
34 Testing for lossless decomposition property(1/6) R given schema with attributes A 1,A 2,, A n F given set of FDs D {R 1,R 2,, R m } given decomposition of R Is D a lossless decomposition? Create an m n matrix S with columns labeled as A 1,A 2,, A n and rows labeled as R 1,R 2,, R m Initialize the matrix as follows: set S(i,j) as symbol b ij for all i,j. if A j is in the scheme R i, then set S(i,j) as symbol a j, for all i,j 34
35 Testing for lossless decomposition property(2/6) After S is initialized, we carry out the following process on it: repeat for each functional dependency U V in F do for all rows in S which agree on U-attributes do make the symbols in each V- attribute column the same in all the rows as follows: if any of the rows has an a symbol for the column set the other rows to the same a symbol in the column else // if no a symbol exists in any of the rows choose one of the b symbols that appears in one of the rows for the V-attribute and set the other rows to that b symbol in the column until no changes to S At the end, if there exists a row with all a symbols then D is lossless otherwise D is a lossy decomposition 35
36 Testing for lossless decomposition property(3/6) R = (rollno, name, advisor, advisordept, course, grade) FD s = { rollno name; rollno advisor; advisor advisordept rollno, course grade} D : { R 1 = (rollno, name, advisor), R 2 = (advisor, advisordept), R 3 = (rollno, course, grade) } Matrix S : (Initial values) rollno name advisor advisor Dept course grade R 1 a 1 a 2 a 3 b 14 b 15 b 16 R 2 b 21 b 22 a 3 a 4 b 25 b 26 R 3 a 1 b 32 b 33 b 34 a 5 a 6 36
37 Testing for lossless decomposition property(4/6) R = (rollno, name, advisor, advisordept, course, grade) FD s = { rollno name; rollno advisor; advisor advisordept rollno, course grade} D : { R 1 = (rollno, name, advisor), R 2 = (advisor, advisordept), R 3 = (rollno, course, grade) } Matrix S : (After enforcing rollno name & rollno advisor) rollno name advisor advisor Dept course grade R 1 a 1 a 2 a 3 b 14 b 15 b 16 R 2 b 21 b 22 a 3 a 4 b 25 b 26 R 3 a 1 b 32 a 2 b 33 a 3 b 34 a 5 a 6 37
38 Testing for lossless decomposition property(5/6) R = (rollno, name, advisor, advisordept, course, grade) FD s = { rollno name; rollno advisor; advisor advisordept rollno, course grade} D : { R 1 = (rollno, name, advisor), R 2 = (advisor, advisordept), R 3 = (rollno, course, grade) } Matrix S : (After enforcing advisor advisordept ) rollno name advisor advisor Dept course grade R 1 a 1 a 2 a 3 b 14 a 4 b 15 b 16 R 2 b 21 b 22 a 3 a 4 b 25 b 26 R 3 a 1 b 32 a 2 b 33 a 3 b 34 a 4 a 5 a 6 No more changes. Third row with all a symbols. So a lossless join. 38
39 Testing for lossless decomposition property(6/6) R given schema. F given set of FDs The decomposition of R into R 1, R 2 is lossless wrt F if and only if either R 1 R 2 (R 1 R 2 ) belongs to F + or R 1 R 2 (R 2 R 1 ) belongs to F + Eg. gradeinfo (rollno, studname, course, grade) with FDs = {rollno, course grade; studname, course grade; rollno studname; studname rollno} decomposed into grades (rollno, course, grade) and studinfo (rollno, studname) is lossless because rollno studname 39
40 A property of lossless joins D 1 : (R 1, R 2,, R K ) lossless decomposition of R wrt F D 2 : (R i1, R i2,, R ip ) lossless decomposition of R i wrt F i = p Ri (F) Then D = (R 1, R 2,, R i-1, R i1, R i2,, R ip, R i+1,, R k ) is a lossless decomposition of R wrt F This property is useful in the algorithm for BCNF decomposition 40
41 Algorithm for BCNF decomposition R given schema. F given set of FDs D = {R} // initial decomposition while there is a relation schema R i in D that is not in BCNF do { let X A be the FD in R i violating BCNF; Replace R i by R i1 = R i {A} and R i2 = X {A} in D; } Decomposition of R i is lossless as R i1 R i2 = X, R i2 R i1 = A and X A Result: a lossless decomposition of R into BCNF relations 41
42 Dependencies may not be preserved (1/2) Consider the schema: towninfo (statename, townname, distname) with the FDs F: ST D (town names are unique within a state) D S Keys: ST, DT. all attributes are prime relation in 3NF Relation is not in BCNF as D S and D is not a key Decomposition given by algorithm: R 1 : TD R 2 : DS Not dependency preserving as p R1 (F) = trivial dependencies p R2 (F) = {D S} Union of these doesn t imply ST D ST D can t be enforced unless we perform a join. S T D 42
43 Dependencies may not be preserved (2/2) Consider the schema: R (A, B, C) with the FDs F: AB C and C B Keys: AB, AC relation in 3NF (all attributes are prime) Relation is not in BCNF as C B and C is not a key Decomposition given by algorithm: R 1 : CB R 2 : AC Not dependency preserving as p R1 (F) = trivial dependencies p R2 (F) = {C B} Union of these doesn t imply AB C All possible decompositions: {AB, BC}, {BA, AC}, {AC, CB} Only the last one is lossless! Lossless and dependency-preserving decomposition doesn't exist. 43
44 Equivalent Dependency Sets F, G two sets of FDs on schema R F is said to cover G if G F + (equivalently G + F + ) F is equivalent to G if F + = G + (or, F covers G and G covers F) Note: To check if F covers G, it s enough to show that for each FD X Y in G, Y X + F 44
45 Canonical covers or Minimal covers It is of interest to reduce a set of FDs F into a standard form F such that F is equivalent to F. We define that a set of FDs F is in minimal form if (i) the rhs of any FD of F is a single attribute (ii) there are no redundant FDs in F that is, there is no FD X A in F s.t (F {X A}) is equivalent to F (iii) there are no redundant attributes on the lhs of any FD in F that is, there is no FD X A in F s.t there is Z X for which F {X A} {Z A} is equivalent to F Minimal Covers useful in obtaining a lossless, dependency-preserving decomposition of a scheme R into 3NF relation schemas 45
46 Algorithm for computing a minimal cover R given Schema or set of attributes; F given set of fd s on R Step 1: G := F Step 2: Replace every fd of the form X A 1 A 2 A 3 A k in G by X A 1 ; X A 2 ; X A 3 ; ; X A k Step 3: For each fd X A in G do for each B in X do if A (X B) + wrt G then replace X A by (X B) A Step 4: For each fd X A in G do if (G { X A}) + =G + then replace G by G { X A} 46
47 3NF decomposition algorithm R given Schema; F given set of fd s on R in minimal form Use BCNF algorithm to get a lossless decomposition D = (R 1, R 2,,R k ) Note: each R i is already in 3NF (it is in BCNF in fact!) Algorithm: Let G be the set of fd s not preserved in D For each fd Z A that is in G Add relation scheme S = (B 1,B 2,, B s,a) to D. // Z = {B 1,B 2,, B s } As Z A is in F which is a minimal cover, there is no proper subset X of Z s.t X A. So Z is a key for S! Any other fd X C on S is such that C is in {B 1,B 2,, B s }. Such fd s do not violate 3NF because each B j s is prime a attribute! Thus any scheme S added to D as above is in 3NF. D continues to be lossless even when we add new schemas to it! 47
48 Multi-valued Dependencies (MVDs) studcourse (rollno,courseno, addr) a student enrolls for several courses and has several addresses rollno courseno ( read as rollno multi-determines courseno ) If (CS05B007, CS370, [email protected]) (CS05B007, CS376, [email protected]) appear in the data then (CS05B007, CS376, [email protected]) (CS05B007, CS370, [email protected]) should also appear for, otherwise, it implies that having gmail address has something to with doing course CS370!! By symmetry, rollno addr 48
49 More about MVDs Consider studcoursegrade(rollno,courseno,grade) Note that rollno courseno does not hold here even though courseno is a multi-valued attribute of student If (CS05B007, CS370, A) (CS05B007, CS376, B) appear in the data then (CS05B007, CS376, A) (CS05B007, CS370, B) will not appear!! Attribute grade depends on (rollno,courseno) MVD s arise when two unrelated multi-valued attributes of an entity are sought to be represented together. 49
50 More about MVDs Consider studcourseadvisor(rollno,courseno,advisor) Note that rollno courseno holds here If (CS05B007, CS370, Dr Ravi) (CS05B007, CS376, Dr Ravi) appear in the data then swapping courseno values gives rise to existing tuples only. But, since rollno advisor and (rollno, courseno) is the key, this gets caught in checking for 2NF itself. 50
51 Alternative definition of MVDs Consider R(X,Y,Z) Suppose that X Y and by symmetry X Z Then, decomposition D = (XY, XZ) should be lossless That is, for any instance r on R, r = π XY (r) * π XZ (r) 51
52 MVDs and 4NF An MVD X Y on scheme R is called trivial if either Y X or R = X Y. Otherwise, it is called nontrivial. 4NF: A relation R is in 4NF if it is in BCNF and for every nontrivial MVD X A, X must be a superkey of R. studcourse (rollno,courseno, addr) is not in 4NF as rollno courseno and rollno addr are both nontrivial and rollno is not a superkey for the relation 52
Relational Database Design
Relational Database Design To generate a set of relation schemas that allows - to store information without unnecessary redundancy - to retrieve desired information easily Approach - design schema in appropriate
Database Design and Normalization
Database Design and Normalization CPS352: Database Systems Simon Miner Gordon College Last Revised: 9/27/12 Agenda Check-in Functional Dependencies (continued) Design Project E-R Diagram Presentations
Theory of Relational Database Design and Normalization
Theory of Relational Database Design and Normalization (Based on Chapter 14 and some part of Chapter 15 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3) 1 Informal Design Guidelines for
COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1
COSC344 Database Theory and Applications Lecture 9 Normalisation COSC344 Lecture 9 1 Overview Last Lecture Functional Dependencies This Lecture Normalisation Introduction 1NF 2NF 3NF BCNF Source: Section
Chapter 10. Functional Dependencies and Normalization for Relational Databases
Chapter 10 Functional Dependencies and Normalization for Relational Databases Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant
Design of Relational Database Schemas
Design of Relational Database Schemas T. M. Murali October 27, November 1, 2010 Plan Till Thanksgiving What are the typical problems or anomalies in relational designs? Introduce the idea of decomposing
Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31
Databases -Normalization III (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31 This lecture This lecture describes 3rd normal form. (N Spadaccini 2010 and W Liu 2012) Databases -
Schema Refinement, Functional Dependencies, Normalization
Schema Refinement, Functional Dependencies, Normalization MSCI 346: Database Systems Güneş Aluç, University of Waterloo Spring 2015 MSCI 346: Database Systems Chapter 19 1 / 42 Outline 1 Introduction Design
Schema Design and Normal Forms Sid Name Level Rating Wage Hours
Entity-Relationship Diagram Schema Design and Sid Name Level Rating Wage Hours Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke 1 Database Management Systems, 2 nd Edition. R. Ramakrishnan
Chapter 7: Relational Database Design
Chapter 7: Relational Database Design Database System Concepts, 5th Ed. See www.db book.com for conditions on re use Chapter 7: Relational Database Design Features of Good Relational Design Atomic Domains
Schema Refinement and Normalization
Schema Refinement and Normalization Module 5, Lectures 3 and 4 Database Management Systems, R. Ramakrishnan 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational
CS143 Notes: Normalization Theory
CS143 Notes: Normalization Theory Book Chapters (4th) Chapters 7.1-6, 7.8, 7.10 (5th) Chapters 7.1-6, 7.8 (6th) Chapters 8.1-6, 8.8 INTRODUCTION Main question How do we design good tables for a relational
Functional Dependencies and Normalization
Functional Dependencies and Normalization 5DV119 Introduction to Database Management Umeå University Department of Computing Science Stephen J. Hegner [email protected] http://www.cs.umu.se/~hegner Functional
Relational Database Design: FD s & BCNF
CS145 Lecture Notes #5 Relational Database Design: FD s & BCNF Motivation Automatic translation from E/R or ODL may not produce the best relational design possible Sometimes database designers like to
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Outline Informal Design Guidelines
Functional Dependencies and Finding a Minimal Cover
Functional Dependencies and Finding a Minimal Cover Robert Soulé 1 Normalization An anomaly occurs in a database when you can update, insert, or delete data, and get undesired side-effects. These side
normalisation Goals: Suppose we have a db scheme: is it good? define precise notions of the qualities of a relational database scheme
Goals: Suppose we have a db scheme: is it good? Suppose we have a db scheme derived from an ER diagram: is it good? define precise notions of the qualities of a relational database scheme define algorithms
Database Management Systems. Redundancy and Other Problems. Redundancy
Database Management Systems Winter 2004 CMPUT 391: Database Design Theory or Relational Normalization Theory Dr. Osmar R. Zaïane Lecture 2 Limitations of Relational Database Designs Provides a set of guidelines,
Week 11: Normal Forms. Logical Database Design. Normal Forms and Normalization. Examples of Redundancy
Week 11: Normal Forms Database Design Database Redundancies and Anomalies Functional Dependencies Entailment, Closure and Equivalence Lossless Decompositions The Third Normal Form (3NF) The Boyce-Codd
Relational Database Design Theory
Relational Database Design Theory Informal guidelines for good relational designs Functional dependencies Normal forms and normalization 1NF, 2NF, 3NF BCNF, 4NF, 5NF Inference rules on functional dependencies
Theory behind Normalization & DB Design. Satisfiability: Does an FD hold? Lecture 12
Theory behind Normalization & DB Design Lecture 12 Satisfiability: Does an FD hold? Satisfiability of FDs Given: FD X Y and relation R Output: Does R satisfy X Y? Algorithm: a.sort R on X b.do all the
Database Management System
UNIT -6 Database Design Informal Design Guidelines for Relation Schemas; Functional Dependencies; Normal Forms Based on Primary Keys; General Definitions of Second and Third Normal Forms; Boyce-Codd Normal
Theory of Relational Database Design and Normalization
Theory of Relational Database Design and Normalization (Based on Chapter 14 and some part of Chapter 15 in Fundamentals of Database Systems by Elmasri and Navathe) 1 Informal Design Guidelines for Relational
Relational Normalization Theory (supplemental material)
Relational Normalization Theory (supplemental material) CSE 532, Theory of Database Systems Stony Brook University http://www.cs.stonybrook.edu/~cse532 2 Quiz 8 Consider a schema S with functional dependencies:
Why Is This Important? Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) Example (Contd.)
Why Is This Important? Schema Refinement and Normal Forms Chapter 19 Many ways to model a given scenario in a database How do we find the best one? We will discuss objective criteria for evaluating database
Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example
Limitations of E-R Designs Relational Normalization Theory Chapter 6 Provides a set of guidelines, does not result in a unique database schema Does not provide a way of evaluating alternative schemas Normalization
Advanced Relational Database Design
APPENDIX B Advanced Relational Database Design In this appendix we cover advanced topics in relational database design. We first present the theory of multivalued dependencies, including a set of sound
Chapter 10 Functional Dependencies and Normalization for Relational Databases
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright 2004 Pearson Education, Inc. Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of
Determination of the normalization level of database schemas through equivalence classes of attributes
Computer Science Journal of Moldova, vol.17, no.2(50), 2009 Determination of the normalization level of database schemas through equivalence classes of attributes Cotelea Vitalie Abstract In this paper,
Chapter 8. Database Design II: Relational Normalization Theory
Chapter 8 Database Design II: Relational Normalization Theory The E-R approach is a good way to start dealing with the complexity of modeling a real-world enterprise. However, it is only a set of guidelines
Functional Dependency and Normalization for Relational Databases
Functional Dependency and Normalization for Relational Databases Introduction: Relational database design ultimately produces a set of relations. The implicit goals of the design activity are: information
Lecture Notes on Database Normalization
Lecture Notes on Database Normalization Chengkai Li Department of Computer Science and Engineering The University of Texas at Arlington April 15, 2012 I decided to write this document, because many students
Normalisation. Why normalise? To improve (simplify) database design in order to. Avoid update problems Avoid redundancy Simplify update operations
Normalisation Why normalise? To improve (simplify) database design in order to Avoid update problems Avoid redundancy Simplify update operations 1 Example ( the practical difference between a first normal
Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES
1 Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES INFORMAL DESIGN GUIDELINES FOR RELATION SCHEMAS We discuss four informal measures of quality for relation schema design in
How To Find Out What A Key Is In A Database Engine
Database design theory, Part I Functional dependencies Introduction As we saw in the last segment, designing a good database is a non trivial matter. The E/R model gives a useful rapid prototyping tool,
Chapter 10. Functional Dependencies and Normalization for Relational Databases. Copyright 2007 Ramez Elmasri and Shamkant B.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright 2007 Ramez Elmasri and Shamkant B. Navathe Chapter Outline 1 Informal Design Guidelines for Relational Databases
CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University
CS 377 Database Systems Database Design Theory and Normalization Li Xiong Department of Mathematics and Computer Science Emory University 1 Relational database design So far Conceptual database design
Database Design and Normalization
Database Design and Normalization Chapter 10 (Week 11) EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 1 Computing Closure F + Example: List all FDs with: - a single
Limitations of DB Design Processes
Normalization CS 317/387 1 Limitations of DB Design Processes Provides a set of guidelines, does not result in a unique database schema Does not provide a way of evaluating alternative schemas Pitfalls:
6.830 Lecture 3 9.16.2015 PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization
6.830 Lecture 3 9.16.2015 PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization Animals(name,age,species,cageno,keptby,feedtime) Keeper(id,name)
Relational Normalization: Contents. Relational Database Design: Rationale. Relational Database Design. Motivation
Relational Normalization: Contents Motivation Functional Dependencies First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form Decomposition Algorithms Multivalued Dependencies and
Introduction to Database Systems. Normalization
Introduction to Database Systems Normalization Werner Nutt 1 Normalization 1. Anomalies 1. Anomalies 2. Boyce-Codd Normal Form 3. 3 rd Normal Form 2 Anomalies The goal of relational schema design is to
Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 5: Normalization II; Database design case studies. September 26, 2005
Introduction to Databases, Fall 2005 IT University of Copenhagen Lecture 5: Normalization II; Database design case studies September 26, 2005 Lecturer: Rasmus Pagh Today s lecture Normalization II: 3rd
Database Constraints and Design
Database Constraints and Design We know that databases are often required to satisfy some integrity constraints. The most common ones are functional and inclusion dependencies. We ll study properties of
Normalization of Database
Normalization of Database UNIT-4 Database Normalisation is a technique of organizing the data in the database. Normalization is a systematic approach of decomposing tables to eliminate data redundancy
Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina
Normalisation to 3NF Database Systems Lecture 11 Natasha Alechina In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third Normal Forms For more
SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints
DBS Database Systems Designing Relational Databases Peter Buneman 12 October 2010 SQL DDL In its simplest use, SQL s Data Definition Language (DDL) provides a name and a type for each column of a table.
Functional Dependencies
BCNF and 3NF Functional Dependencies Functional dependencies: modeling constraints on attributes stud-id name address course-id session-id classroom instructor Functional dependencies should be obtained
RELATIONAL DATABASE DESIGN
RELATIONAL DATABASE DESIGN g Good database design - Avoiding anomalies g Functional Dependencies g Normalization & Decomposition Using Functional Dependencies g 1NF - Atomic Domains and First Normal Form
Chapter 7: Relational Database Design
Chapter 7: Relational Database Design Pitfalls in Relational Database Design Decomposition Normalization Using Functional Dependencies Normalization Using Multivalued Dependencies Normalization Using Join
Quiz 3: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354
Quiz 3: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354 1. [10] Show that each of the following are not valid rules about FD s by giving a small example relations that satisfy the given
Normalisation in the Presence of Lists
1 Normalisation in the Presence of Lists Sven Hartmann, Sebastian Link Information Science Research Centre, Massey University, Palmerston North, New Zealand 1. Motivation & Revision of the RDM 2. The Brouwerian
An Algorithmic Approach to Database Normalization
An Algorithmic Approach to Database Normalization M. Demba College of Computer Science and Information Aljouf University, Kingdom of Saudi Arabia [email protected] ABSTRACT When an attempt is made to
Normalization in Database Design
in Database Design Marek Rychly [email protected] Strathmore University, @ilabafrica & Brno University of Technology, Faculty of Information Technology Advanced Databases and Enterprise Systems 14
CSCI-GA.2433-001 Database Systems Lecture 7: Schema Refinement and Normalization
CSCI-GA.2433-001 Database Systems Lecture 7: Schema Refinement and Normalization Mohamed Zahran (aka Z) [email protected] http://www.mzahran.com View 1 View 2 View 3 Conceptual Schema At that point we
Objectives of Database Design Functional Dependencies 1st Normal Form Decomposition Boyce-Codd Normal Form 3rd Normal Form Multivalue Dependencies
Objectives of Database Design Functional Dependencies 1st Normal Form Decomposition Boyce-Codd Normal Form 3rd Normal Form Multivalue Dependencies 4th Normal Form General view over the design process 1
Database Systems Concepts, Languages and Architectures
These slides are for use with Database Systems Concepts, Languages and Architectures Paolo Atzeni Stefano Ceri Stefano Paraboschi Riccardo Torlone To view these slides on-screen or with a projector use
Normalisation and Data Storage Devices
Unit 4 Normalisation and Data Storage Devices Structure 4.1 Introduction 4.2 Functional Dependency 4.3 Normalisation 4.3.1 Why do we Normalize a Relation? 4.3.2 Second Normal Form Relation 4.3.3 Third
Lecture 2 Normalization
MIT 533 ระบบฐานข อม ล 2 Lecture 2 Normalization Walailuk University Lecture 2: Normalization 1 Objectives The purpose of normalization The identification of various types of update anomalies The concept
Introduction Decomposition Simple Synthesis Bernstein Synthesis and Beyond. 6. Normalization. Stéphane Bressan. January 28, 2015
6. Normalization Stéphane Bressan January 28, 2015 1 / 42 This lecture is based on material by Professor Ling Tok Wang. CS 4221: Database Design The Relational Model Ling Tok Wang National University of
DATABASE NORMALIZATION
DATABASE NORMALIZATION Normalization: process of efficiently organizing data in the DB. RELATIONS (attributes grouped together) Accurate representation of data, relationships and constraints. Goal: - Eliminate
Normalization for Relational DBs
Chapter 7 Functional Dependencies & Normalization for Relational DBs Truong Quynh Chi [email protected] Spring- 2013 Top-Down Database Design Mini-world Requirements E1 R Relation schemas Conceptual
Introduction to Database Systems. Chapter 4 Normal Forms in the Relational Model. Chapter 4 Normal Forms
Introduction to Database Systems Winter term 2013/2014 Melanie Herschel [email protected] Université Paris Sud, LRI 1 Chapter 4 Normal Forms in the Relational Model After completing this chapter,
Boyce-Codd Normal Form
4NF Boyce-Codd Normal Form A relation schema R is in BCNF if for all functional dependencies in F + of the form α β at least one of the following holds α β is trivial (i.e., β α) α is a superkey for R
Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010
Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010 Student Name: ID: Part 1: Multiple-Choice Questions (17 questions, 1
Normalization in OODB Design
Normalization in OODB Design Byung S. Lee Graduate Programs in Software University of St. Thomas St. Paul, Minnesota [email protected] Abstract When we design an object-oriented database schema, we need
MCQs~Databases~Relational Model and Normalization http://en.wikipedia.org/wiki/database_normalization
http://en.wikipedia.org/wiki/database_normalization Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy. Normalization usually involves
Normalization of database model. Pazmany Peter Catholic University 2005 Zoltan Fodroczi
Normalization of database model Pazmany Peter Catholic University 2005 Zoltan Fodroczi Closure of an attribute set Given a set of attributes α define the closure of attribute set α under F (denoted as
Normalization. CIS 331: Introduction to Database Systems
Normalization CIS 331: Introduction to Database Systems Normalization: Reminder Why do we need to normalize? To avoid redundancy (less storage space needed, and data is consistent) To avoid update/delete
6.2 Permutations continued
6.2 Permutations continued Theorem A permutation on a finite set A is either a cycle or can be expressed as a product (composition of disjoint cycles. Proof is by (strong induction on the number, r, of
Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.
Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden Robert C. Nickerson ISYS
DATABASE DESIGN: NORMALIZATION NOTE & EXERCISES (Up to 3NF)
DATABASE DESIGN: NORMALIZATION NOTE & EXERCISES (Up to 3NF) Tables that contain redundant data can suffer from update anomalies, which can introduce inconsistencies into a database. The rules associated
Design Theory for Relational Databases: Functional Dependencies and Normalization
Design Theory for Relational Databases: Functional Dependencies and Normalization Juliana Freire Some slides adapted from L. Delcambre, R. Ramakrishnan, G. Lindstrom, J. Ullman and Silberschatz, Korth
4. FIRST STEPS IN THE THEORY 4.1. A
4. FIRST STEPS IN THE THEORY 4.1. A Catalogue of All Groups: The Impossible Dream The fundamental problem of group theory is to systematically explore the landscape and to chart what lies out there. We
Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3)
Announcements IT0: Database Management and Organization Normalization (Chapter 3) Department coin design contest deadline - February -week exam Monday, February 1 Lab SQL SQL Server: ALTER TABLE tname
A Web-Based Environment for Learning Normalization of Relational Database Schemata
A Web-Based Environment for Learning Normalization of Relational Database Schemata Nikolay Georgiev September 2008 Master s Thesis in Computing Science, 30 ECTS credits Supervisor at CS-UmU: Stephen J.
Normalization. Normalization. Normalization. Data Redundancy
Normalization Normalization o Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data, its relationships, and constraints.
A. TRUE-FALSE: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ:
GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ: Review Quiz will contain very similar question as below. Some questions may even be repeated. The order of the questions are random and are not in order of
Normal forms and normalization
Normal forms and normalization An example of normalization using normal forms We assume we have an enterprise that buys products from different supplying companies, and we would like to keep track of our
a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2.
Chapter 1 LINEAR EQUATIONS 1.1 Introduction to linear equations A linear equation in n unknowns x 1, x,, x n is an equation of the form a 1 x 1 + a x + + a n x n = b, where a 1, a,..., a n, b are given
Math 312 Homework 1 Solutions
Math 31 Homework 1 Solutions Last modified: July 15, 01 This homework is due on Thursday, July 1th, 01 at 1:10pm Please turn it in during class, or in my mailbox in the main math office (next to 4W1) Please
LOGICAL DATABASE DESIGN
MODULE 8 LOGICAL DATABASE DESIGN OBJECTIVE QUESTIONS There are 4 alternative answers to each question. One of them is correct. Pick the correct answer. Do not guess. A key is given at the end of the module
BCA. Database Management System
BCA IV Sem Database Management System Multiple choice questions 1. A Database Management System (DBMS) is A. Collection of interrelated data B. Collection of programs to access data C. Collection of data
TYPICAL QUESTIONS & ANSWERS
TYPICAL QUESTIONS & ANSWERS PART -I OBJECTIVE TYPE QUESTIONS Each Question carries 2 marks. Choosethe correct or the best alternative in the following: Q.1 Which of the following relational algebra operations
Objectives, outcomes, and key concepts. Objectives: give an overview of the normal forms and their benefits and problems.
Normalization Page 1 Objectives, outcomes, and key concepts Tuesday, January 6, 2015 11:45 AM Objectives: give an overview of the normal forms and their benefits and problems. Outcomes: students should
Chapter 9: Normalization
Chapter 9: Normalization Part 1: A Simple Example Part 2: Another Example & The Formal Stuff A Problem: Keeping Track of Invoices (cont d) Suppose we have some invoices that we may or may not want to refer
3. Database Design. 3.1. Functional Dependency. 3.1.01. Introduction. 3.1.02. Value in design. 3.1.03. Initial state. 3.1.05. Aims
of 18 05/03/2007 07:37 3. Database Design This is the Database Design course theme. [Complete set of notes PDF 295Kb]. 3.1. Functional Dependency In this lecture we look at... [Section notes PDF 64Kb]
Database Normalization. Mohua Sarkar, Ph.D Software Engineer California Pacific Medical Center 415-600-7003 sarkarm@sutterhealth.
Database Normalization Mohua Sarkar, Ph.D Software Engineer California Pacific Medical Center 415-600-7003 [email protected] Definition A database is an organized collection of data whose content
INCIDENCE-BETWEENNESS GEOMETRY
INCIDENCE-BETWEENNESS GEOMETRY MATH 410, CSUSM. SPRING 2008. PROFESSOR AITKEN This document covers the geometry that can be developed with just the axioms related to incidence and betweenness. The full
Matrix Representations of Linear Transformations and Changes of Coordinates
Matrix Representations of Linear Transformations and Changes of Coordinates 01 Subspaces and Bases 011 Definitions A subspace V of R n is a subset of R n that contains the zero element and is closed under
Normalization. CIS 3730 Designing and Managing Data. J.G. Zheng Fall 2010
Normalization CIS 3730 Designing and Managing Data J.G. Zheng Fall 2010 1 Overview What is normalization? What are the normal forms? How to normalize relations? 2 Two Basic Ways To Design Tables Bottom-up:
MODULE 8 LOGICAL DATABASE DESIGN. Contents. 2. LEARNING UNIT 1 Entity-relationship(E-R) modelling of data elements of an application.
MODULE 8 LOGICAL DATABASE DESIGN Contents 1. MOTIVATION AND LEARNING GOALS 2. LEARNING UNIT 1 Entity-relationship(E-R) modelling of data elements of an application. 3. LEARNING UNIT 2 Organization of data
C HAPTER 4 INTRODUCTION. Relational Databases FILE VS. DATABASES FILE VS. DATABASES
INRODUCION C HAPER 4 Relational Databases Questions to be addressed in this chapter: How are s different than file-based legacy systems? Why are s important and what is their advantage? What is the difference
Approximation Algorithms
Approximation Algorithms or: How I Learned to Stop Worrying and Deal with NP-Completeness Ong Jit Sheng, Jonathan (A0073924B) March, 2012 Overview Key Results (I) General techniques: Greedy algorithms
KNOWLEDGE FACTORING USING NORMALIZATION THEORY
KNOWLEDGE FACTORING USING NORMALIZATION THEORY J. VANTHIENEN M. SNOECK Katholieke Universiteit Leuven Department of Applied Economic Sciences Dekenstraat 2, 3000 Leuven (Belgium) tel. (+32) 16 28 58 09
If it's in the 2nd NF and there are no non-key fields that depend on attributes in the table other than the Primary Key.
Normalization First Normal Form (1st NF) The table cells must be of single value. Eliminate repeating groups in individual tables. Create a separate table for each set of related data. Identify each set
060010102 Database Management Systems 2015
Module 1- File Organization and Structure Short Questions: 1. How data differs from information? 2. What are the different types of cache memory? 3. List at least two devices where flash memory is used.
