1 Normalization. 2 Normal Forms v If a relation is in a certain normal form (BCNF, 3NF etc.), it is known that certain kinds of redundancies are avoided/minimized.

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Schema Refinement and Normal Forms
Normalisation to 3NF Database Systems Lecture 11 Natasha Alechina.
Normalization 1 Instructor: Mohamed Eltabakh Part II.
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.
NORMALIZATION FIRST NORMAL FORM (1NF): A relation R is in 1NF if all attributes have atomic value = one value for an attribute = no repeating groups =
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
Relational Normalization Theory. Limitations of E-R Designs Provides a set of guidelines, does not result in a unique database schema Does not provide.
Recap of Feb 13: SQL, Relational Calculi, Functional Dependencies SQL: multiple group bys, having, lots of examples Tuple Calculus Domain Calculus Functional.
Normalization DB Tuning CS186 Final Review Session.
Normalization DB Tuning CS186 Final Review Session.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
1 Normalization Chapter What it’s all about Given a relation, R, and a set of functional dependencies, F, on R. Assume that R is not in a desirable.
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 9.
Schema Refinement and Normal Forms. The Evils of Redundancy v Redundancy is at the root of several problems associated with relational schemas: – redundant.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
1 Schema Refinement and Normal Forms Chapter 19 Raghu Ramakrishnan and J. Gehrke (second text book) In Course Pick-up box tomorrow.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
Normalization. FarkasCSCE 5202 Reading Assignments  Database Systems The Complete Book: Chapters 3.6, 3.7, 3.8  Following lecture slides are modified.
Cs3431 Normalization Part II. cs3431 Attribute Closure : Example Consider R (A, B, C, D, E) with FDs A  B, B  C, CD  E Does A  E hold ? (Is A  E.
1 Schema Refinement and Normal Forms Yanlei Diao UMass Amherst April 10, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Department of Computer Science and Engineering, HKUST Slide 1 7. Relational Database Design.
1 Lecture 7: Schema refinement: Normalisation
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.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Schema Refinement and Normal Forms Chapter 19 Instructor: Mirsad Hadzikadic.
Schema Refinement and Normal Forms Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Relational Database Design by Relational Database Design by Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
CSCD34 - Data Management Systems - A. Vaisman1 Schema Refinement and Normal Forms.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
Schema Refinement and Normalization. Functional Dependencies (Review) A functional dependency X  Y holds over relation schema R if, for every allowable.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Normalization for Relational Databases.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Schema Refinement and Normal Forms Chapter 19 1 Database Management Systems 3ed, R.Ramakrishnan & J.Gehrke.
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.
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.
THIRD NORMAL FORM (3NF) A relation R is in BCNF if whenever a FD XA holds in R, one of the following statements is true: XA is a trivial FD, or X is.
Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization for Relational Databases
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh
Functional Dependencies and Normalization R&G Chapter 19 Lecture 26 Science is the knowledge of consequences, and dependence of one fact upon another.
Revisit FDs & BCNF Normalization 1 Instructor: Mohamed Eltabakh
Christoph F. Eick: Functional Dependencies, BCNF, and Normalization 1 Functional Dependencies, BCNF and Normalization.
Functional Dependencies And Normalization R&G Chapter 19.
Database Systems/COMP4910/Spring02/Melikyan1 Schema Refinement and Normal Forms.
1 Schema Refinement and Normal Forms Week 6. 2 The Evils of Redundancy  Redundancy is at the root of several problems associated with relational schemas:
Third Normal Form (3NF) Zaki Malik October 23, 2008.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 15.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Design Process - Where are we?
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
Normalization.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
CS 338Database Design and Normal Forms9-1 Database Design and Normal Forms Lecture Topics Measuring the quality of a schema Schema design with normalization.
1 Schema Refinement and Normal Forms Chapter The Evils of Redundancy  Redundancy is at the root of several problems associated with relational.
Ch 7: Normalization-Part 1
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
© 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.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
1 CS122A: Introduction to Data Management Lecture #13: Relational DB Design Theory (II) Instructor: Chen Li.
Schema Refinement and Normal Forms
Schema Refinement and Normalization
Normalization Part II cs3431.
Schema Refinement and Normalization
NORMALIZATION FIRST NORMAL FORM (1NF):
Presentation transcript:

1 Normalization

2 Normal Forms v If a relation is in a certain normal form (BCNF, 3NF etc.), it is known that certain kinds of redundancies are avoided/minimized. This can be used to help us decide whether decomposing the relation will help. v Role of FDs in detecting redundancy: –Consider a relation R with 3 attributes, ABC. u Given A  BC: There is no redundancy here. u Add B C: Several tuples could have the same B value, and if so, they’ll all have the same C value!

3 First Normal Form (1NF) v 1NF: Each field is an atomic (scalar) value v All relations are in first normal form (1NF) v Some definitions we’ll need to understand the other normal forms: –A prime attribute is an attribute that is an element of one or more CKs for a relation. –A trivial FD is one in which the RHS is contained in the LHS (e.g., AB  A or B  B). We will ignore such FDs in this lecture.

4 Second Normal Form (2NF) v Relation R is in 2NF if, for all FDs X  A –A is prime, or –X is not a proper subset of any CK. v Example : R = (part, wh, qty, wh-addr) –FDs: {part, wh}  qty wh  wh-addr –Is R in 2NF?

5 2NF (continued) v No, it’s in 1NF only. Only candidate key is {part, wh}, and second FD violates 2NF. v So what? v We’re storing wh-addr once for each part stored at that warehouse. v Solution: R1 ( ) and R2 ( ) v Are R1, R2 in 2NF?

6 Third Normal Form (3NF) v Relation R is in 3NF if, for all FDs X A –X is a superkey for R, or –A is prime v Example: ED = (enum, ename, sal, dnum, dname, mgr) –FDs: enum  ename, sal, dnum dnum  dname, mgr –Is ED in 2NF?3NF? v The problem: stored for each employee in a department

7 3NF (continued) v One solution: –Emp (enum, ename, sal, mgr) –Dept (dnum, dname, mgr) –Removes the redundancy –A problem remains: v This is an example of a lossy-join decomposition, which is avoidable in 3NF. v Use Emp1 (enum, ename, sal, ) instead of Emp.

8 Boyce-Codd Normal Form (BCNF) v Relation R is in BCNF if, for all FDs X A –X is a superkey v Example: R = (branch, cust, banker) –FDs: banker  branch cust, branch  banker –Is R in 3NF?BCNF? v Problems: –Bankers must have at least one customer –Branch stored redundantly for each of a banker’s customers

9 BCNF (continued) v Decomposition: R1 (banker, branch) and R2 (cust, banker) –avoids redundancy and other problems –A problem remains: v In this case, no dependency-preserving decomposition into BCNF is possible.

10 Problems with Decompositions v There are three potential problems to consider: ¶ Some queries become more expensive. u e.g., find employee and department names · Given instances of the decomposed relations, we may not be able to reconstruct the corresponding instance of the original relation! u First 3NF decomposition attempt ¸ Checking some dependencies may require joining the instances of the decomposed relations. u BCNF decomposition example v Tradeoff : Must consider these issues vs. redundancy.

11 Summary of Schema Refinement v If a relation is in BCNF, it is free of redundancies that can be detected using FDs. v If a relation is not in BCNF, we can try to decompose it into a collection of BCNF relations: –Lossless-join, dependency preserving decomposition into BCNF is not always possible –Lossless-join decomposition into BCNF is always possible –Lossless-join, dependency preserving decomposition into 3NF is always possible –Decompositions should be carried out and/or re-examined while keeping performance requirements in mind. –Various decompositions of a single schema are possible.