Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 5 The Relational Model and Normalization.

Similar presentations


Presentation on theme: "© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 5 The Relational Model and Normalization."— Presentation transcript:

1 © 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 5 The Relational Model and Normalization

2 © 2002 by Prentice Hall 2 The Relational Model Broad, flexible model Basis for almost all DBMS products E.F. Codd defined well-structured “normal forms” of relations, “normalization”

3 © 2002 by Prentice Hall 3 Components of the Relational Model Relation –A two-dimensional table consisting of rows and columns Tuples –The rows (or records) in a relation Attributes –The columns (or fields) in a relation

4 © 2002 by Prentice Hall 4 Terminology

5 © 2002 by Prentice Hall 5 Functional Dependency Functional dependencies are the relationships among the attributes within a relation. If attribute A functional depends on attribute B, then for every instance of B you will know the respective value of A.

6 © 2002 by Prentice Hall 6 Functional Dependency Notation Major is functionally dependent on SID SID  Major Grade is functionally dependent on the combination of SID and ClassID (SID, ClassID)  Grade

7 © 2002 by Prentice Hall 7 Functional Dependency – an Example EmployeeNumber  Name EmployeeNumber  Age EmployeeNumber  Sex

8 © 2002 by Prentice Hall 8 A Key A key is a group of one or more attributes that uniquely identifies a tuple

9 © 2002 by Prentice Hall 9 A Combination Key Sometimes more than one attribute will be required to uniquely identify a tuple. If a key consists of more than one attribute, it is called a combination (or composite) key.

10 © 2002 by Prentice Hall 10 Example of a Combination Key

11 © 2002 by Prentice Hall 11 Normalization Normalization is a process of evaluating and converting a relation to reduce modification anomalies Essentially, normalization detects and eliminates data redundancy

12 © 2002 by Prentice Hall 12 An Anomaly An anomaly is an undesirable consequence of a data modification.

13 © 2002 by Prentice Hall 13 Normal Forms Normal forms are state-classes of relations which identify the level of anomaly-avoidance

14 © 2002 by Prentice Hall 14 Normal Forms Levels 1NF –First Normal Form 2NF –Second Normal Form 3NF –Third Normal Form BCNF –Boyce-Codd Normal Form 4NF –Fourth Normal Form 5NF –Fifth Normal Form DK/NF –Domain/Key Normal Form

15 © 2002 by Prentice Hall 15 First Normal Form (1NF) To be in First Normal Form (1NF) a relation must have only single-valued attributes -- neither repeating groups nor arrays are permitted

16 © 2002 by Prentice Hall 16 Violation of 1NF PlayerIDNameTeamAtBatsHits 123-45- 6789 Alomar, RCleveland, New York 200, 120 50, 58 234-56- 7890 Alomar, SCleveland, Chicago 60, 150 17, 40 Key: PlayerID Determinants: PlayerID -> Name, Team, AtBats, Hits

17 © 2002 by Prentice Hall 17 Second Normal Form (2NF) To be in Second Normal Form (2NF) the relation must be in 1NF and each nonkey attribute must be dependent on the whole key (not a subset of the key)

18 © 2002 by Prentice Hall 18 Violation of 2NF ItemNoCustomerIDQuantityCreditRtg 125725OK 346793Poor Key: ItemNo, CustomerID Determinants: ItemNo, CustomerID -> Quantity CustomerID -> CreditRtg

19 © 2002 by Prentice Hall 19 Third Normal Form (3NF) To be in Third Normal Form (3NF) the relation must be in 2NF and no transitive dependencies may exist within the relation. A transitive dependency is when an attribute is indirectly functionally dependent on the key (that is, the dependency is through another nonkey attribute)

20 © 2002 by Prentice Hall 20 Violation of 3NF

21 © 2002 by Prentice Hall 21 Boyce-Codd Normal Form (BCNF) To be in Boyce-Codd Normal Form (BCNF) the relation must be in 3NF and every determinant must be a candidate key.

22 © 2002 by Prentice Hall 22 Violation of BCNF ClientProbTypeConsultant AlphaMarketingGomez AlphaProductionRaginski BetaMarketingGomez OmegaMarketingTaylor Key: Client, ProbType Candidate Key: Client, Consultant Determinants: Consultant-> ProbType * No two consultants have same name * Consultant specializes in just one problem type * Consultant can be assigned to multiple clients

23 © 2002 by Prentice Hall 23 Fourth Normal Form (4NF) To be in Fourth Normal Form (4NF) the relation must be in BCNF and the relation may not contain multi-valued dependencies.

24 © 2002 by Prentice Hall 24 Fifth Normal Form (5NF) The Fifth Normal Form concerns dependencies that are obscure and beyond the scope of this text.

25 © 2002 by Prentice Hall 25 Domain/Key Normal Form (DK/NF) To be in Domain/Key Normal Form (DK/NF) every constraint on the relation must be a logical consequence of the definition of keys and domains.

26 © 2002 by Prentice Hall 26 Summary of Normal Forms

27 © 2002 by Prentice Hall 27 Optimization De-Normalization (a.k.a., Controlled Redundancy)

28 © 2002 by Prentice Hall 28 David M. Kroenke Database Processing Eighth Edition Chapter 5 The Relational Model and Normalization


Download ppt "© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 5 The Relational Model and Normalization."

Similar presentations


Ads by Google