1 Database Design Issues, Part I Hugh Darwen CS252.HACD: Fundamentals of Relational Databases Section.

Slides:



Advertisements
Similar presentations
Relational Algebra Part II
Advertisements

Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4.
Addition Facts
Fourth normal form: 4NF 1. 2 Normal forms desirable forms for relations in DB design eliminate redundancies avoid update anomalies enforce integrity constraints.
5NF and other normal forms
1 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Normalisation 5.
Functional dependencies 1. 2 Outline motivation: update anomalies cause: not expressed constraints on data (FDs) functional dependencies (FDs) definitions.
Dependency preservation, 3NF revisited and BCNF
Normal forms - 1NF, 2NF and 3NF
1 Term 2, 2004, Lecture 2, Normalisation - IntroductionMarian Ursu, Department of Computing, Goldsmiths College Normalisation Introduction.
1 Term 2, 2007, Lectures 2/3, NormalisationD. Tidhar (based on M. Ursu) Department of Computing, Goldsmiths College Normalisation 5.
1 Introduction to Relational Databases Hugh Darwen CS252.HACD: Fundamentals of Relational Databases.
1 Constraints and Updating Hugh Darwen CS252.HACD: Fundamentals of Relational Databases Section 7: Constraints.
CS 319: Theory of Databases
1 Relational Algebra, Part III, and Other Operators Hugh Darwen CS252.HACD: Fundamentals of Relational.
1 Relational Algebra, Principles and Part I Hugh Darwen CS252.HACD: Fundamentals of Relational Databases.
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.
1 Values, Types, Variables, Operators Hugh Darwen CS252.HACD: Fundamentals of Relational Databases Section.
Dr. A.I. Cristea CS 319: Theory of Databases: FDs.
1 Predicates and Propositions Hugh Darwen CS252.HACD: Fundamentals of Relational Databases Section 3:
Chapter 5 Normalization of Database Tables
Normalization of Database Tables
1 Week 4: Normalisation: Redundant data becomes inconsistent data; therefore … “The key, the whole key, and nothing but the key,so help me, Codd”
Functional Dependencies (FDs)
Functional Dependencies and Normalization for Relational Databases
Addition 1’s to 20.
Shantanu Narang.  Background  Why and What of Normalization  Quick Overview of Lower Normal Forms  Higher Order Normal Forms.
Normalisation to 3NF Database Systems Lecture 11 Natasha Alechina.
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.
1 Database Design Issues, Part II Hugh Darwen CS252.HACD: Fundamentals of Relational Databases Section.
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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Normalization I.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Lecture 12 Inst: Haya Sammaneh
Database Systems Normal Forms. Decomposition Suppose we have a relation R[U] with a schema U={A 1,…,A n } – A decomposition of U is a set of schemas.
Copyright © Curt Hill Schema Refinement III 4 th NF and 5 th NF.
King Henry viii All about his wives. Catherine of Aragon Was his first wife Was his first wife Born in 1485 Born in 1485 When she was 18 and Henry was.
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,
Normalization. Learners Support Publications 2 Objectives u The purpose of normalization. u The problems associated with redundant data.
1 Pertemuan 23 Normalisasi Matakuliah: >/ > Tahun: > Versi: >
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Your name here. Improving Schemas and Normalization What are redundancies and anomalies? What are functional dependencies and how are they related to.
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.
Normalization Ioan Despi 2 The basic objective of logical modeling: to develop a “good” description of the data, its relationships and its constraints.
CSE314 Database Systems Basics of Functional Dependencies and Normalization for Relational Databases Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
IST 210 Normalization 2 Todd Bacastow IST 210. Normalization Methods Inspection Closure Functional dependencies are key.
NORMALIZATION. What is Normalization  The process of effectively organizing data in a database  Two goals  To eliminate redundant data  Ensure data.
Ch 7: Normalization-Part 1
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.
Dr. T. Y. Lin | SJSU | CS 157A | Fall 2015 Chapter 3 Database Normalization 1.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
Advanced Database System
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Advanced Normalization
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
STRUCTURE OF PRESENTATION :
Advanced Normalization
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Module 5: Overview of Normalization
Normalization.
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Sampath Jayarathna Cal Poly Pomona
Chapter 7a: Overview of Database Design -- Normalization
Presentation transcript:

1 Database Design Issues, Part I Hugh Darwen CS252.HACD: Fundamentals of Relational Databases Section 8: Database Design Issues, Part I

2 A Reducible Relation Wife#FirstNameLastNameFate 1Catherineof Aragondivorced 2AnneBoleynbeheaded 3JaneSeymourdied 4Anneof Clevesdivorced 5CatherineHowardbeheaded 6CatherineParrsurvived WIFE_OF_HENRY_VIII (Note the underscoring of the primary key attribute.)

3 Decomposing H8s Wives Wife#FirstName 1Catherine 2Anne 3Jane 4Anne 5Catherine 6 W_FN Wife#LastNameFate 1of Aragondivorced 2Boleynbeheaded 3Seymourdied 4of Clevesdivorced 5Howardbeheaded 6Parrsurvived W_LN_F

4 Join Dependency The join dependency (JD) that holds in WIFE_OF_HENRY_VIII and allows us to decompose in W_FN and W_LN_F is written like this: * { { Wife#, FirstName }, { Wife#, LastName, Fate } } The star indicates a JD. The operands of a JD are written inside braces. Each operand is a set of attributes, hence the inner braces. If a given JD holds in relvar r, then at all times r = the join of the projections indicated by the operands of the JD.

5 A Join Dependency That Does Not Hold Although W_FN is irreducible, we can of course take several projections of it, the following two in particular: Wife# W_FN { Wife# } FirstName Catherine Anne Jane W_FN { FirstName } But the JOIN of these two does not yield W_FN, so the JD *{ { Wife# }, { FirstName} } does not hold in W_FN.

6 Decomposition of W_LN_F W_LN_F can be further decomposed: Wife#LastName 1of Aragon 2Boleyn 3Seymour 4of Cleves 5Howard 6Parr W_LN Wife#Fate 1divorced 2beheaded 3died 4divorced 5beheaded 6survived W_F

7 3-Way Join Dependency So the following JD holds in W_LN_F: * { { Wife#, LastName }, { Wife#, Fate } } and we can conclude that the following 3-way JD holds in WIFE_OF_HENRY_VIII: * { { Wife#, FirstName }, { Wife#, LastName }, { Wife#, Fate } } i.e., WIFE_OF_HENRY_VIII = WIFE_OF_HENRY_VIII { Wife#, FirstName } JOIN WIFE_OF_HENRY_VIII { Wife#, LastName } JOIN WIFE_OF_HENRY_VIII { Wife#, Fate }

8 Design Comparison Does the decomposed design have any advantages? The single relvar design carries an implicit constraint to the effect that every wife has a wife number, a first name, a last name and a fate. This constraint is not implicit in the decomposed design. In fact, to enforce it, each of W_FN, W_LN and W_F needs a foreign key referencing each of the other two. But then the first attempt to insert a tuple into any of them must fail (unless multiple assignment is available).

9 Conclusion In the example at hand, the single relvar design is preferred, so long as the constraint implied by it truly reflects the real world. (For example, if it turns out that in fact not every wife has a last name, then we should separate out W_LN.) But the example at hand is rather special: Each operand of the 3-way JD that holds in WIFE_OF_HENRY_VIII includes a key of that relvar and it is the same key in each case, viz. {Wife#} We need to look at some not-so-special examples.

10 A Not-So-Special JD StudentIdNameCourseId S1AnneC1 S1AnneC2 S2BorisC1 S3CindyC3 S4DevinderC1 ENROLMENT Recall that we decided to split (i.e., decompose) this one, as follows …

11 Splitting ENROLMENT StudentIdName S1Anne S2Boris S3Cindy S4Devinder StudentIdCourseId S1C1 S1C2 S2C1 S3C3 S4C1 IS_CALLEDIS_ENROLLED_ON Notice the JD: *{ { StudentId, Name }, { StudentId, CourseId } } that holds in ENROLMENT.

12 Functional Dependency Because {StudentId} is a key of the projection ENROLMENT{StudentId, Name}, we say that the following functional dependency (FD) holds in ENROLMENT: { StudentId } { Name } The arrow, pronounced determines, indicates an FD. Each operand is a set of attributes (hence the braces). Name is a function of StudentId. For each StudentId there is exactly one Name.

13 Anatomy of an FD A B The determinant determines The dependant set Reminder: The determinant is a set of attributes, and so is the dependant set. P.S. dependant is not a misspelling! Its the noun, not the adjective.

14 FDs That Do Not Hold in ENROLMENT { Name } { StudentId } { Name } { CourseId } { CourseId } { StudentId } { CourseId, Name } { StudentId } { StudentId } { CourseId } { StudentId, Name } { CourseId } also: { x } { StudentId }, because x is not an attribute of ENROLMENT.

15 Theorems About FDs Left-Augmentation: If A is a superset of A, then A B holds in r. Assume A B holds in r. Then: Right-reduction: If B is a subset of B, then A B holds in r. Transitivity: If A B and B C hold in r, then A C holds in r. In general: If A B and C D hold in r, then: A U ( C – B ) B U D holds in r.

16 Left-Irreducibility If A B holds in r and there is no proper subset A of A such that A B holds in r, then A B is a left-irreducible FD (in r). In this case, B is sometimes said to be fully dependent on A. Conversely, if there is such a subset A, then A B is a left- reducible FD (in r), and B is therefore not fully dependent on A.

17 FDs and Keys If A B is a left-irreducible FD in r and A U B constitutes the entire heading of r, then A is a key of r. If A B is an FD in r and A U B constitutes the entire heading of r, then A is a superkey of r. (The longer term candidate key is often used instead of key, for historical reasons.)

18 Normal Forms Arising from the study of JDs in general and FDs in particular, various normal forms have been defined: First Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF) Boyce/Codd Normal Form (BCNF) Fourth Normal Form (4NF) Fifth Normal Form (5NF) Sixth Normal Form (6NF) Each of these is in a sense stricter than its immediate predecessor. The ones shown in bold are particularly important. The others were early attempts that eventually proved inadequate.

19 Normalisation Normalisation is the act of decomposing a relvar that fails to satisfy a given normal form (e.g., BCNF) such that the result is an equivalent set of two or more smaller relvars that do satisfy that normal form. We decompose by taking the projections specified in a given join dependency (JD). In the case of ENROLMENT, the given JD is *{ { StudentId, Name }, {StudentId, CourseId } } determined by the FD { StudentId } { Name }

20 Purposes of Normalisation A database all of whose relvars satisfy 6NF has the following possibly desirable properties: No redundancy (i.e., no recording of the same information more than once) No update anomalies (to be explained later) Orthogonality (independent recording of the simplest facts) But 5NF is usually sufficient (and 6NF is sometimes problematical with existing technology), as we shall see …