Chapter 10 Functional Dependencies and Normalization for Relational Databases.

Slides:



Advertisements
Similar presentations
Functional Dependencies and Normalization for Relational Databases
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources.
NORMALIZATION. Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations.
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.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
Ch 10, Functional Dependencies and Normal forms
Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization for Relational Databases
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
METU Department of Computer Eng Ceng 302 Introduction to DBMS Functional Dependencies and Normalization for Relational Databases by Pinar Senkul resources:
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
Databases 6: Normalization
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Announcements Homework 1 due Friday. Slip it under my office door (1155) or put in my mailbox on 5 th floor. Program 2 has been graded ;-( Program 3 out.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Functional Dependencies and Normalization for Relational Databases.
FUNCTIONAL DEPENDENCIES. Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant Information.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 6 NORMALIZATION FOR RELATIONAL DATABASES Instructor Ms. Arwa Binsaleh.
King Saud University College of Computer & Information Sciences Computer Science Department CS 380 Introduction to Database Systems Functional Dependencies.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Normalization for Relational Databases.
DatabaseIM ISU1 Chapter 10 Functional Dependencies and Normalization for RDBs Fundamentals of Database Systems.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Topic 10 Functional Dependencies and Normalization for Relational Databases Faculty of Information Science and Technology Mahanakorn University of Technology.
Instructor: Churee Techawut Functional Dependencies and Normalization for Relational Databases Chapter 4 CS (204)321 Database System I.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Normalization.
Top-Down Database Design Mini-world Requirements Conceptual schema E1 E2 R Relation schemas ?
Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
Chapter Functional Dependencies and Normalization for Relational Databases.
CSE314 Database Systems Basics of Functional Dependencies and Normalization for Relational Databases Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E.
Functional Dependencies and Normalization Jose M. Peña
1 Functional Dependencies and Normalization Chapter 15.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Lecture 8: Database Concepts May 4, Outline From last lecture: creating views Normalization.
Deanship of Distance Learning Avicenna Center for E-Learning 1 Session - 7 Sequence - 2 Normalization Functional Dependencies Presented by: Dr. Samir Tartir.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 5 Introduction to a First Course in Database Systems.
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
10/3/2017.
Functional Dependency and Normalization
Functional Dependencies and Normalization for Relational Databases
Normalization Functional Dependencies Presented by: Dr. Samir Tartir
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization for RDBs
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Database Management systems Subject Code: 10CS54 Prepared By:
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Relational Database Design
Presentation transcript:

Chapter 10 Functional Dependencies and Normalization for Relational Databases

Informal Design Guidelines for Relation Schemas (1/4) GUIDELINE 1: Design a relation schema so that it is easy to explain its meaning. Do not combine attributes from multiple entity types and relationship types into a single relation. Intuitively, if a relation schema corresponds to one entity type or one relationship type, the meaning tends to be clear. Otherwise, the relation corresponds to a mixture of multiple entities and relationships and hence becomes semantically unclear.

Informal Design Guidelines for Relation Schemas (2/4) GUIDELINE 2: Design the base relation schemas so that no insertion, deletion, or modification anomalies are present in the relations. If any anomalies are present, note them clearly and make sure that the programs that update the database will operate correctly.

Informal Design Guidelines for Relation Schemas (3/4) GUIDELINE 3: As far as possible, avoid placing attributes in a base relation whose values may frequently be null. If nulls are unavoidable, make sure that they apply in exceptional cases only and do not apply to a majority of tuples in the relation.

Informal Design Guidelines for Relation Schemas (4/4) GUIDELINE 4: Design relation schemas so that they can be JOINed with equality conditions on attributes that are either primary keys or foreign keys in a way that guarantees that no spurious tuples are generated. Do not have relations that contain matching attributes other than foreign key-primary key combinations. If such relations are unavoidable, do not join them on such attributes, because the join may produce spurious tuples.

Functional Dependencies

Definition of Functional Dependency (1/4) A functional dependency, denoted by X  Y, between two sets of attributes X and Y that are subsets of R specifies a constraint on the possible tuples that can form a relation state r of R. X functionally determines Y in a relation schema R if and only if, whenever two tuples of r(R) agree on their X-value, they must necessarily agree on their Y-value.

Definition of Functional Dependency (2/4) If X is a candidate key of R, this implies that X  Y for any subset of attributes Y of R. If X  Y in R, this does not say whether or not Y  X in R.

Definition of Functional Dependency (3/4) A functional dependency is a property of the semantics or meaning of the attributes. Whenever the semantics of two sets of attributes in R indicate that a functional dependency should hold, we specify the dependency as a constraint. Relation extensions r(R) that satisfy the functional dependency constraints are called legal extensions (or legal relation states) of R, because they obey the functional dependency constraints.

Definition of Functional Dependency (4/4) A functional dependency is a property of the relation schema (intension) R, not of a particular legal relation state (extension) r of R. Hence, an FD cannot be inferred automatically from a given relation extension r but must be defined explicitly by someone who knows the semantics of the attributes of R.

Inference Rules for Functional Dependencies (1/7) We denote by F the set of functional dependencies that are specified on relation schema R. An FD X  Y is inferred from a set of dependencies F specified on R if X  Y holds in every relation state r that is a legal extension of R; that is, whenever r satisfies all the dependencies in F, X  Y also holds in r. The closure F + of F is the set of all functional dependencies that can be inferred from F.

Inference Rules for Functional Dependencies (2/7) IR1 (reflexive rule): If X  Y, then X  Y. IR2 (augmentation rule): {X  Y }  XZ  YZ. IR3 (transitive rule): {X  Y, Y  Z}  X  Z. IR4 (decomposition, or projective, rule): {X  YZ}  X  Y. IR5 (union, or additive, rule): {X  Y, X  Z}  X  YZ. IR6 (pseudotransitive rule): {X  Y, WY  Z }  WX  Z.

Inference Rules for Functional Dependencies (3/7) It has been shown by Armstrong (1974) that inference rules IR1 through IR3 are sound and complete.

Inference Rules for Functional Dependencies (4/7) Typically, database designers first specify the set of functional dependencies F that can easily be determined from the semantics of the attributes of R; then IR1, IR2, and IR3 are used to infer additional functional dependencies that will also hold on R.

Inference Rules for Functional Dependencies (5/7) A systematic way to determine these additional functional dependencies is first to determine each set of attributes X that appears as a left-hand side of some functional dependency in F and then to determine the set of all attributes that are dependent on X. Thus for each such set of attributes X, we determine the set X + of attributes that are functionally determined by X based on F; X + is called the closure of X under F.

Inference Rules for Functional Dependencies (6/7) Algorithm 14.1 Determining X +, the closure of X under F X + := X; repeat old X + := X + ; for each functional dependency Y  Z in F do if X +  Y then X + := X +  Z; until (X + = old X + );

Inference Rules for Functional Dependencies (7/7) F ={SSN  ENAME, PNUMBER  {PNAME, PLOCATION}, {SSN, PNUMBER}  HOURS} Using Algorithm 14.1, we calculate the following closure sets with respect to F: { SSN } + = { SSN, ENAME } { PNUMBER } + = { PNUMBER, PNAME, PLOCATION } { SSN, PNUMBER } + = { SSN, PNUMBER, ENAME, PNAME, PLOCATION, HOURS }

Equivalence of Sets of Functional Dependencies (1/4) A set of functional dependencies E is covered by a set of functional dependencies F—or alternatively, F is said to cover E—if every FD in E is also in F + ; that is, if every dependency in E can be inferred from F.

Equivalence of Sets of Functional Dependencies (2/4) Two sets of functional dependencies E and F are equivalent if E + = F +. Hence, equivalence means that every FD in E can be inferred from F, and every FD in F can be inferred from E; that is, E is equivalent to F if both the conditions E covers F and F covers E hold.

Equivalence of Sets of Functional Dependencies (3/4) We can determine whether F covers E by calculating X + with respect to F for each FD X  Y in E, and then checking whether this X + includes the attributes in Y. If this is the case for every FD in E, then F covers E.

Equivalence of Sets of Functional Dependencies (4/4) We determine whether E and F are equivalent by checking that E covers F and F covers E.

Minimal Sets of Functional Dependencies (1/3) A set of functional dependencies F is minimal if it satisfies the following conditions: –Every dependency in F has a single attribute for its right-hand side. –We cannot replace any dependency X  A in F with a dependency Y  A, where Y is a proper subset of X, and still have a set of dependencies that is equivalent to F. –We cannot remove any dependency from F and still have a set of dependencies that is equivalent to F.

Minimal Sets of Functional Dependencies (2/3) A minimal cover of a set of functional dependencies F is a minimal set of dependencies F min that is equivalent to F. Unfortunately, there can be several minimal covers for a set of functional dependencies.

Minimal Sets of Functional Dependencies (3/3) Algorithm 14.2 Finding a minimal cover G for F –Set G := F. –Replace each functional dependency X  {A 1, A 2, …, A n } in G by the n functional dependencies X  A 1, X  A 2,..., X  A n. –For each functional dependency X  A in G for each attribute B that is an element of X if ((G - {X  A}) D {(X - {B})  A}) is equivalent to G, then replace X  A with (X - {B})  A in G. –For each remaining functional dependency X  A in G if (G - {X  A}) is equivalent to G, then remove X  A from G.

Normal Forms Based on Primary Keys

Introduction to Normalization (1/5) Normalization of data is a process of analyzing the given relation schemas based on their FDs and primary keys to achieve the desirable properties of (1) minimizing redundancy and (2) minimizing the insertion, deletion, and update anomalies. Unsatisfactory relation schemas that do not meet certain conditions—the normal form tests—are decomposed into smaller relation schemas that meet the tests and hence possess the desirable properties.

Introduction to Normalization (2/5) Normal forms, when considered in isolation from other factors, do not guarantee a good database design. It is generally not sufficient to check separately that each relation schema in the database is, say, in BCNF or 3NF.

Introduction to Normalization (3/5) The process of normalization through decomposition must also confirm the existence of additional properties that the relational schemas, taken together, should possess. These would include two properties: –The lossless join or nonadditive join property –The dependency preservation property

Introduction to Normalization (4/5) Database design as practiced in industry today pays particular attention to normalization up to BCNF or 4NF. The database designers need not normalize to the highest possible normal form. –The process of storing the join of higher normal form relations as a base relation—which is in a lower normal form—is known as denormalization.

Introduction to Normalization (5/5) An attribute of relation schema R is called a prime attribute of R if it is a member of some candidate key of R. An attribute is called nonprime if it is not a prime attribute—that is, if it is not a member of any candidate key.

First Normal Form First normal form (1NF) states that the domain of an attribute must include only atomic (simple, indivisible) values and that the value of any attribute in a tuple must be a single value from the domain of that attribute.

Second Normal Form (1/2) A functional dependency X  Y is a full functional dependency if removal of any attribute A from X means that the dependency does not hold any more; that is, for any attribute A  X, (X - {A}) does not functionally determine Y. A functional dependency X  Y is a partial dependency if some attribute A  X can be removed from X and the dependency still holds; that is, for some A  X, (X - {A})  Y.

Second Normal Form (2/2) A relation schema R is in 2NF if every nonprime attribute A in R is fully functionally dependent on the primary key of R.

Third Normal Form (1/2) A functional dependency X  Y in a relation schema R is a transitive dependency if there is a set of attributes Z that is neither a candidate key nor a subset of any key of R, and both X  Z and Z  Y hold.

Third Normal Form (2/2) A relation schema R is in 3NF if it satisfies 2NF and no nonprime attribute of R is transitively dependent on the primary key.

General Definitions of Second and Third Normal Forms

General Definition of Second Normal Form A relation schema R is in second normal form (2NF) if every nonprime attribute A in R is not partially dependent on any key of R.

General Definition of Third Normal Form A relation schema R is in third normal form (3NF) if, whenever a nontrivial functional dependency X  A holds in R, either (a) X is a superkey of R, or (b) A is a prime attribute of R.

Boyce-Codd Normal Form A relation schema R is in BCNF if whenever a nontrivial functional dependency X  A holds in R, then X is a superkey of R.