Announcements Read 5.8 – 5.13 for Monday Project Step 3, due Monday 10/18 Homework 4, due Friday 10/15 – by email (or turn in Monday in class)

Slides:



Advertisements
Similar presentations
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Advertisements

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.
ALAK ROY. Assistant Professor Dept. of CSE NIT Agartala N ATIONAL I NSTITUTE OF T ECHNOLOGY A GARTALA Aug-Dec,2010 Normalization 2 CSE-503 :: D ATABASE.
Announcements Read 5.1 – 5.5 for today Read 5.6 – 5.7 for Wednesday Project Step 3, due Monday 10/18 Homework, due Friday 10/15 – by Research paper,
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.
+ Review: Normalization and data anomalies CSCI 2141 W2013 Slide set modified from courses.ischool.berkeley.edu/i257/f06/.../Lecture06_257.ppt.
Functional Dependencies and Normalization for Relational Databases.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 David M. Kroenke’s Chapter Three: The Relational Model and Normalization.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
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
METU Department of Computer Eng Ceng 302 Introduction to DBMS Relational Database Design Algorithms by Pinar Senkul resources: mostly froom Elmasri, Navathe.
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Functional Dependencies and Normalization for Relational Databases.
IS 230Lecture 8Slide 1 Normalization Lecture 9. IS 230Lecture 8Slide 2 Lecture 8: Normalization 1. Normalization 2. Data redundancy and anomalies 3. Spurious.
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.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Objectives of Normalization Develop a good description of the data, its relationships and constraints Produce a stable set of relations that Is a faithful.
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.
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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide DESIGNING A SET OF RELATIONS (2) Goals: Lossless join property (a must). Dependency.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Normalization.
SCUJ. Holliday - coen 1784–1 Schedule Today: u Normal Forms. u Section 3.6. Next u Relational Algebra. Read chapter 5 to page 199 After that u SQL Queries.
Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Normalization Ioan Despi 2 The basic objective of logical modeling: to develop a “good” description of the data, its relationships and its constraints.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 11 Relational Database Design Algorithms and Further Dependencies.
Chapter Functional Dependencies and Normalization for Relational Databases.
1 Functional Dependencies and Normalization Chapter 15.
ABSTRACT OF FIRST LECTURE then … the second lesson.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Design Process - Where are we?
Announcements Program 3 due Friday Homework 2 out today, due Mon Read: Chapter 3.
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 Sept. 2014ACS-3902 Yangjun Chen1 Outline: Normalization Redundant information and update anomalies Function dependencies Normal forms -1NF,
CS 222 Database Management System Spring Lecture 5 Database Design (Decomposition) Korra Sathya Babu Department of Computer Science NIT Rourkela.
Normalization.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
Databases Illuminated Chapter 6 Normalization. Objectives of Normalization Develop a good description of the data, its relationships and constraints Produce.
Databases Illuminated
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
CS 405G: Introduction to Database Systems Database Normalization.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 David M. Kroenke’s Chapter Three: The Relational Model and 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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Relational Database Design Algorithms and Further Dependencies.
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.
Copyright © Curt Hill Schema Refinement II 2 nd NF to 3 rd NF to BCNF.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
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.
Functional Dependency and Normalization
Announcements Read 5.1 – 5.5 for today Read 5.6 – 5.7 for Wednesday
Outline: Normalization
Normalization.
Normalization February 28, 2019 DB:Normalization.
Presentation transcript:

Announcements Read 5.8 – 5.13 for Monday Project Step 3, due Monday 10/18 Homework 4, due Friday 10/15 – by (or turn in Monday in class)

Normalization through BCNF and Relational Decompositions and Design Lecture 13

Full Functional Dependency In relation R, set of attributes B is fully functionally dependent on set of attributes A of R if B is functionally dependent on A but not functionally dependent on any proper subset of A This means

Partial Functional Dependency Example NewClass(courseNo, stuId, stuLastName, facId, schedule, room, grade) FDs: {courseNo,stuId} → {lastName} {courseNo,stuId} →{facId} {courseNo,stuId} →{schedule} {courseNo,stuId} →{room} {courseNo,stuId} →{grade} …plus trivial FDs that are partial…

Second Normal Form A relation is in second normal form (2NF) if it is in first normal form and No non-key attribute is FD on just part of the key If key has only one attribute, and R is 1NF, R is automatically 2NF

Converting to 2NF Identify each partial FD Remove the attributes that depend on each of the determinants so identified Place these determinants in separate relations along with their dependent attributes In original relation keep the composite key and any attributes that are fully functionally dependent on all of it Even if the composite key has no dependent attributes, keep that relation to connect logically the others

2NF Example NewClass(courseNo, stuId, stuLastName, facId, schedule, room, grade ) FDs grouped by determinant: {courseNo} → {stuId} → {courseNo,stuId} → Create tables grouped by determinants: {courseNo,stuId} →{grade} courseNo → facId courseNo → schedule courseNo →room stuId → lastName {courseNo,stuId} →{grade} courseNo → facId courseNo → schedule courseNo →room stuId → lastName

Transitive Dependency If A, B, and C are attributes of relation R, such that A → B, and B → C, then C is transitively dependent on A Example: NewStudent (stuId, lastName, major, credits, status) FD: credits→status By transitivity: stuId→credits  credits→status implies stuId→status Transitive dependencies cause update, insertion, deletion anomalies.

Third Normal Form A relation is in third normal form (3NF) if To be 3NF, relation must be 2NF and have no transitive dependencies –Here key includes “candidate key”

Making a relation 3NF For example, NewStudent (stuId, lastName, major, credits, status) with FD credits→status Remove the dependent attribute, status, from the relation Create a new table with the dependent attribute and its determinant, credits Keep the determinant in the original table

Review First (1 NF) – Relation should have no nonatomic attributes or nested relations Second (2 NF) – For relations where primary key contains multiple attributes, no nonkey attribute should be functionally dependent on part of the primary key Third (3 NF) – Relation should not have a nonkey attribute functionally determined by another nonkey attribute (of by a set of nonkey attributes.)

Boyce-Codd Normal Form A relation is in Boyce/Codd Normal Form (BCNF) if Stricter than 3NF, which allows A to be part of a candidate key If there is just one single candidate key, the forms are equivalent

Example NewFac (facName, dept, office, rank, dateHired) FDs: office → dept facName,dept → office, rank, dateHired facName,office → dept, rank, dateHired NewFac is not BCNF because office is not a superkey To make it BCNF, remove the dependent attributes to a new relation, with the determinant as the key Project into Fac1 (office, dept) Fac2 (facName, office, rank, dateHired) Note we have lost a functional dependency in Fac2 – no longer able to see that {facName, dept} is a determinant, since they are in different relations

Properties of Decompositions Starting with a universal relation that contains all the attributes, we can decompose into relations by projection A decomposition of a relation R is a set of relations {R 1,R 2,...,R n } such that each R i is a subset of R and the union of all of the R i is R. Desirable properties of decompositions –Attribute preservation – –Dependency preservation – –Lossless decomposition –

Dependency Preservation If R is decomposed into {R 1,R 2,…,R n,} so that for each functional dependency X→Y all the attributes in X  Y appear in the same relation, R i, then all FDs are preserved Allows DBMS to check each FD constraint by checking just one table for each

Example of Lossy Projection Original EmpRoleProj table: EmpNameroleprojName SmithdesignerNile SmithprogrammerAmazon SmithdesignerAmazon JonesdesignerAmazon Project into Table aTable b EmpNameroleroleprojName SmithdesignerdesignerNile Smithprogrammerprogrammer Amazon Jonesdesignerdesigner Amazon Joining Table a and Table b produces EmpNameroleprojName Note: in this example there are no FDs

Lossless Decomposition A decomposition of R into {R 1, R 2,....,R n } is lossless if the natural join of R 1, R 2,...,R n produces exactly the relation R No spurious tuples are created when the projections are joined. Always possible to find a BCNF decomposition that is lossless Nonadditive join

Algorithmic Test for Lossless Join Given a relation R(A1, A2, …, An), a set of functional dependencies, F, and a decomposition of R into relations R1, R2, …, Rm 1.Construct an m by n table S, with a column for each of the n attributes in R and a row for each of the m relations in the decomposition 2.For each cell S(i,j) of S, If the attribute for the column, Aj, is in the relation for the row, Ri, then place the symbol a(j) in the cell; else place the symbol b(i,j) there

Algorithmic Test for Lossless Join (Continued) 3.Repeat the following process until no more changes can be made to S: For each FD X → Y in F For all rows in S that have the same symbols in the columns corresponding to the attributes of X, make the symbols for the columns that represent the attributes of Y equal by the following rule: if any row has an a value, a(j), then set the value of that column in all other rows equal to a(j) if no row has an a value, then pick any one of the b values, say b(i,j), and all the other rows equal to b(i,j) 4.If, after all possible changes have been made to S, a row is made up entirely of a symbols, a(1), a(2), …, a(n), then the join is lossless. It there is no such row, the join is lossy.

R = {SSN, ENAME, PNUMBER, PNAME, PLOCATION, HOURS} R1 = EMP_LOCS={ENAME, PLOCATION} R2 = EMP_PROJ1={SSN, PNUMBER, HOURS, PNAME, PLOCATION} F={SSN→ENAME; PNUMBER→{PNAME, PLOCATION}; {SNN, PNUMBER}→HOURS SSNENAMEPNUMBERPNAMEPLOCATIONHOURS R1 R2

R = {SSN, ENAME, PNUMBER, PNAME, PLOCATION, HOURS} R1 = EMP={SSN, ENAME} R2 = PROJ={PNUMBER, PNAME, PLOCATION} R3 = WORKS_ON={SSN, PNUMBER, HOURS} F={SSN→ENAME; PNUMBER→{PNAME, PLOCATION}; {SNN, PNUMBER}→HOURS SSNENAMEPNUMBERPNAMEPLOCATIONHOURS R1 R2 R3

Lossless Projections Lossless property guaranteed if for each pair of relations that will be joined, the set of common attributes is a superkey of one of the relations Binary decomposition of R into {R 1,R 2 } has the lossless join property with respect to a set of functional dependencies F on R iff one of these holds The FD ((R1 ∩ R2) → (R1 - R2)) is in F + or The FD (( R1 ∩ R2) → (R2 - R1 )) is in F + If projection is done by successive binary projections, can apply binary decomposition test repeatedly