Advanced Database System

Slides:



Advertisements
Similar presentations
Dependency preservation, 3NF revisited and BCNF
Advertisements

 Definition  Components  Advantages  Limitations Contents  Definition Definition  Normal Forms Normal Forms  First Normal Form First Normal Form.
Schema Refinement and Normal Forms Given a design, how do we know it is good or not? What is the best design? Can a bad design be transformed into a good.
1/22/20091 Study the methods of first, second, third, Boyce-Codd, fourth and fifth normal form for relational database design, in order to eliminate data.
Boyce-Codd NF Takahiko Saito Spring 2005 CS 157A.
Wei-Pang Yang, Information Management, NDHU More on Normalization Unit 18 More on Normalization ( 表格正規化探討 ) 18-1.
Chapter 3 Notes. 3.1 Functional Dependencies A functional dependency is a statement that – two tuples of a relation that agree on some particular set.
Normalisation The theory of Relational Database Design.
The Relational Model System Development Life Cycle Normalisation
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
Chapter 8 Normal Forms Based on Functional Dependencies Deborah Costa Oct 18, 2007.
Databases 6: Normalization
Normalization II. Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF.
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Functional Dependencies Prof. Yin-Fu Huang CSIE, NYUST Chapter 11.
Normalization B Database Systems Normal Forms Wilhelm Steinbuss Room G1.25, ext. 4041
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Logical Database Design Unit 7 Logical Database Design.
Dr. T. Y. Lin | SJSU | CS 157A | Fall 2015 Chapter 3 Database Normalization 1.
Logical Database Design ( 補 ) Unit 7 Logical Database Design ( 補 )
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
Chapter 13 Further Normalization II: Higher Normal Forms.
NormalizationNormalization Chapter 4. Purpose of Normalization Normalization  A technique for producing a set of relations with desirable properties,
Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)
Normalization. Learners Support Publications 2 Objectives u The purpose of normalization. u The problems associated with redundant data.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Further Normalization II: Higher Normal Forms Prof. Yin-Fu Huang CSIE, NYUST Chapter 13.
CS143 Review: Normalization Theory Q: Is it a good table design? We can start with an ER diagram or with a large relation that contain a sample of the.
CSC271 Database Systems Lecture # 28.
Normalization Ioan Despi 2 The basic objective of logical modeling: to develop a “good” description of the data, its relationships and its constraints.
Further Normalization I
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
CSE314 Database Systems Basics of Functional Dependencies and Normalization for Relational Databases Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E.
Lecture No 14 Functional Dependencies & Normalization ( III ) Mar 04 th 2011 Database Systems.
IST 210 Normalization 2 Todd Bacastow IST 210. Normalization Methods Inspection Closure Functional dependencies are key.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Temple University – CIS Dept. CIS331– Principles of Database Systems V. Megalooikonomou Database Design and Normalization (based on notes by Silberchatz,Korth,
Copyright, Harris Corporation & Ophir Frieder, The Process of Normalization.
Normalization. 2 u Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data,
Normalization.
3 Spring Chapter Normalization of Database Tables.
Relations Prof. Yin-Fu Huang CSIE, NYUST Chapter 6.
Types Prof. Yin-Fu Huang CSIE, NYUST Chapter 5. Advanced Database SystemYin-Fu Huang Relation, tuple, cardinality, attribute, degree, domain, primary.
CS 405G: Introduction to Database Systems Database Normalization.
CS 338Database Design and Normal Forms9-1 Database Design and Normal Forms Lecture Topics Measuring the quality of a schema Schema design with normalization.
Integrity Prof. Yin-Fu Huang CSIE, NYUST Chapter 9.
© D. Wong Functional Dependencies (FD)  Given: relation schema R(A1, …, An), and X and Y be subsets of (A1, … An). FD : X  Y means X functionally.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
11/06/97J-1 Principles of Relational Design Chapter 12.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
Objectives of Normalization  To create a formal framework for analyzing relation schemas based on their keys and on the functional dependencies among.
Copyright © Curt Hill Schema Refinement II 2 nd NF to 3 rd NF to BCNF.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts.
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Dr. T. Y. Lin | SJSU | CS 157A | Fall 2015 Chapter 3 Database Normalization 1.
Advanced Normalization
A brief summary of database normalization
STRUCTURE OF PRESENTATION :
3.1 Functional Dependencies
Handout 4 Functional Dependencies
Advanced Normalization
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Module 5: Overview of Normalization
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Unit 7 Normalization (表格正規化).
Chapter 7a: Overview of Database Design -- Normalization
CS4222 Principles of Database System
Presentation transcript:

Advanced Database System 12.1 Introduction (1/3) Redundancy (See Fig. 12.1) A good design principle is “one fact in one place” The principles of further normalization allow us to recognize the redundancy and to replace the relvars in question by ones that are more desirable in some way. e.g., {S#,City,P#,Qty} {S#,City}, {S#,P#,Qty} Advanced Database System

Advanced Database System 12.1 Introduction (2/3) Normal forms A relvar is said to be in a particular normal form if it satisfies a certain prescribed set of conditions. The normalization procedure is reversible; it means the normalization process is nonloss or information-preserving. Codd: 1NF, 2NF, 3NF, BCNF Fagin: 4NF, PJ/NF (5NF) (See Fig. 12.2) Advanced Database System

Advanced Database System 12.1 Introduction (3/3) Two remarks: 1. Normalization is a useful aid in the process, but it is not a panacea. 2. The ideas of normalization can then be used to verify that the resulting design does not unintentionally violate any of the normalization principles. Advanced Database System

12.2 Nonloss Decomposition and Functional Dependencies Whether a given decomposition is nonloss is intimately bound up with the concept of functional dependence. Decomposition is actually a process of projection. Example (See Fig. 12.3) The reversibility means that the original relvar is equal to the join of its projections. Advanced Database System

12.2 Nonloss Decomposition and Functional Dependencies (Cont.) Heath’s theorem: Let R{A,B,C} be a relvar, where A, B, and C are sets of attributes. If R satisfies the FD A →B, then R is equal to the join of its projections on {A,B} and {A,C}. In case (b), one of the FDs is lost in the decomposition. FD S#→City More on functional dependencies: 1. Irreducibility {S#,P#}→City 2. FD diagrams (See Fig. 12.4) 3. FDs are a semantic notion A special kind of integrity constraint Advanced Database System

12.3 First, Second, and Third Normal Forms (1/6) We assume for simplicity that each relvar has exactly one candidate key, which we further assume is the primary key. Third normal form (very informal definition): A relvar is in 3NF if and only if the nonkey attributes are both: (a) Mutually independent (b) Irreducibly dependent on the primary key. First normal form: A relvar is in 1NF if and only if, in every legal value of that relvar, every tuple contains exactly one value for each attribute. Example (See Fig. 12.5 & 12.6) The primary key of FIRST is {S#,P#}. Advanced Database System

Advanced Database System Fig. 12.5 & 12.6 Advanced Database System

12.3 First, Second, and Third Normal Forms (2/6) Relvar FIRST violates both conditions a and b in our preliminary 3NF definition. Update anomalies corresponding to the FD S#→City After decomposition SECOND(S#,Status,City), SP(S#,P#,Qty) (See Fig. 12.7 & 12.8) Advanced Database System

Advanced Database System Fig. 12.7 & 12.8 Advanced Database System

12.3 First, Second, and Third Normal Forms (3/6) The effect of the decomposition of FIRST into SECOND and SP is to eliminate the dependencies that are not irreducible. Second normal form: A relvar is in 2NF if and only if it is in 1NF and every nonkey attribute is irreducibly dependent on the primary key. In summary R{A,B,C,D} Primary Key {A,B} A →D R1{A,D} Primary Key {A} R2{A,B,C} Foreign Key {A} References R1 Advanced Database System

12.3 First, Second, and Third Normal Forms (4/6) Transitive: If A→B and B→C, then A→C Update anomalies corresponding to the FD City →Status After decomposition SC(S#,City), CS(City, Status) (See Fig. 12.9 & 12.10) Advanced Database System

12.3 First, Second, and Third Normal Forms (5/6) The effect of the further decomposition is to eliminate the transitive dependencies of STATUS on S#. Third normal form: A relvar is in 3NF if and only if it is in 2NF and every nonkey attribute is nontransitively dependent on the primary key. Advanced Database System

12.3 First, Second, and Third Normal Forms (6/6) In summary R{A,B,C} Primary Key {A} B →C R1{B,C} Primary Key {B} R2{A,B} Foreign Key {B} References R1 It is not possible just to look at the value at a given time and to say whether the relvar is in 3NF. Even knowing the dependencies, it is never possible to prove by examining a given value that the relvar is in 3NF. Advanced Database System

12.4 Dependency Preservation (1/3) A given relvar can be nonloss-decomposed in a variety of different ways. Example (See Fig. 12.11) Decomposition A: SC{S#,City} and CS{City,Status} Decomposition B: SC{S#,City} and SS{S#,Status} Advanced Database System

12.4 Dependency Preservation (2/3) Decomposition B is less satisfactory than decomposition A. It is still not possible in B to insert the information that a particular city has a particular status unless some supplier is located in that city. In decomposition A, the two projections are independent of one another. In decomposition B, updates to either of the two projections must be monitored to ensure that the FD City →Status is not violated. Advanced Database System

12.4 Dependency Preservation (3/3) A guideline for independent projections: Rissanen shows that projections R1 and R2 of a relvar R are independent if and only if both of the following are true: 1. Every FD in R is a logical consequence of those in R1 and R2. 2. The common attributes of R1 and R2 form a candidate key for at least one of the pair. A relvar that cannot be decomposed into independent projections is called atomic. The fact that some given relvar is not atomic should not necessarily be taken to mean that it should be decomposed into atomic components. Advanced Database System

12.5 Boyce/Codd Normal Form (1/7) Considering the case of a relvar that 1. Had two or more candidate keys, such that 2. The candidate keys were composite, and 3. They overlapped (i.e., had at least one attribute in common) Boyce/Codd normal form: A relvar is in BCNF if and only if every nontrivial, left-irreducible FD has a candidate key as its determinant. In other words, the only arrows in the FD diagram are arrows out of candidate keys. e.g., FIRST is not in BCNF determinants S#, City, {S#,P#} candidate keys {S#,P#} SECOND is not in BCNF determinants S#, City candidate keys S# SP, SC, and CS are each in BCNF Advanced Database System

12.5 Boyce/Codd Normal Form (2/7) Example: Two disjoint candidate keys S{S#,Sname,Status,City} BCNF (See Fig. 12.12) Advanced Database System

12.5 Boyce/Codd Normal Form (3/7) Example: Overlapping candidate keys SSP{S#,Sname,P#,Qty} determinants S#, Sname, {S#,P#}, {Sname,P#} candidate keys {S#,P#}, {Sname,P#} It is not in BCNF, but is in 3NF. (See Fig. 12.13) Two projections: 1. SS{S#,Sname} and SP{S#,P#,Qty} 2. SS{S#,Sname} and SP{Sname,P#,Qty} Advanced Database System

12.5 Boyce/Codd Normal Form (4/7) Example: Overlapping candidate keys SJT{S,J,T} The constraints: 1. For each subject, each student of that subject is taught by only one teacher. 2. Each teacher teaches only one subject (but each subject is taught by several teachers). (See Fig. 12.14 & 12.15) Advanced Database System

12.5 Boyce/Codd Normal Form (5/7) T is a determinant but not a candidate key. not in BCNF Two projections: ST{S,T} and TJ{T,J} But they are not independent. The FD {S,J}→T cannot be deduced from the FD T →J. Inserting a tuple for Smith and Prof. Brown into relvar ST reject Advanced Database System

12.5 Boyce/Codd Normal Form (6/7) The twin objectives of (a) decomposing a relvar into BCNF components, and (b) decomposing it into independent components can occasionally be in conflict. Relation SJT is atomic in Rissanen’s sense, even though it is not in BCNF. The fact that an atomic relvar cannot be decomposed into independent components does not mean that it cannot be decomposed at all. Advanced Database System

12.5 Boyce/Codd Normal Form (7/7) Example: Overlapping candidate keys EXAM{S,J,P} The constraint: There are no ties; that is, no two students obtained the same position in the same subject. (See Fig. 12.16) Two candidate keys: {S,J}, {J,P} BCNF Advanced Database System

12.6 A Note on Relation-Valued Attributes (1/3) Asymmetric Advanced Database System

12.6 A Note on Relation-Valued Attributes (2/3) Example: 1. Get S# for suppliers who supply part P1 2. Get P# for parts supplied by supplier S1 (SPQ Where Tuple {P# P#(‘P1’)}  PQ {P#}) {S#} ((SPQ Where S# = S# (‘S1’)) Ungroup PQ) {P#} Example: 1. Create a new shipment for supplier S6, part P5, quantity 500 2. Create a new shipment for supplier S2, part P5, Insert SPQ Relation { Tuple { S# S# (‘S6’), PQ Relation { Tuple { P# P#(‘P5’), Qty Qty (500) } } } }; Update SPQ Where S# = S# (‘S2’) { Insert PQ Relation { Tuple { P# P#(‘P5’), Qty Qty (500) } } }; Advanced Database System

12.6 A Note on Relation-Valued Attributes (3/3) However this position should be seen as a guideline only, not as an inviolable law. Var RVK Base Relation { Rvname Name, Ck Relation { Attrname Name } } Key { Rvname, Ck }; (See Fig. 12.18) Advanced Database System

Advanced Database System Fig. 12.18 Advanced Database System

Advanced Database System The End. Advanced Database System