Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Manipulating Functional Dependencies Zaki Malik September 30, 2008.
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)
Functional Dependencies and Normalization for Relational Databases.
Normal Forms. First Normal Form: all table cells must contain atomic values − no sets, arrays, lists, or other collection types − no structured objects.
©Silberschatz, Korth and Sudarshan Relational Database Design First Normal Form Pitfalls in Relational Database Design Functional Dependencies Decomposition.
7.1 Chapter 7: Relational Database Design. 7.2 Chapter 7: Relational Database Design Features of Good Relational Design Atomic Domains and First Normal.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Functional Dependencies and Normalization for Relational Databases
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.
CMSC424: Database Design Instructor: Amol Deshpande
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 9.
Decomposition By Yuhung Chen CS157A Section 2 October
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
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Chapter 7: Relational Database Design. 7.2Unite International CollegeDatabase Management Systems Chapter 7: Relational Database Design Features of Good.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
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.
Computing & Information Sciences Kansas State University Monday, 13 Oct 2008CIS 560: Database System Concepts Lecture 18 of 42 Monday, 13 October 2008.
Chapter 7: Relational Database Design. 7.2Unite International CollegeDatabase Management Systems Chapter 7: Relational Database Design Features of Good.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design Pitfalls in.
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.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
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.
BCNF & Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science.
Computing & Information Sciences Kansas State University Tuesday, 27 Feb 2007CIS 560: Database System Concepts Lecture 18 of 42 Tuesday, 27 February 2007.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 11 Relational Database Design Algorithms and Further Dependencies.
Computing & Information Sciences Kansas State University Wednesday, 04 Oct 2006CIS 560: Database System Concepts Lecture 17 of 42 Wednesday, 04 October.
Chapter Functional Dependencies and Normalization for Relational Databases.
Logical Database Design (1 of 3) John Ortiz Lecture 6Logical Database Design (1)2 Introduction  The logical design is a process of refining DB schema.
Revisit FDs & BCNF Normalization 1 Instructor: Mohamed Eltabakh
Functional Dependencies. FarkasCSCE 5202 Reading and Exercises Database Systems- The Complete Book: Chapter 3.1, 3.2, 3.3., 3.4 Following lecture slides.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
CS 338Database Design and Normal Forms9-1 Database Design and Normal Forms Lecture Topics Measuring the quality of a schema Schema design with normalization.
CS411 Database Systems Kazuhiro Minami 04: Relational Schema Design.
© 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.
Relational Database Design Algorithms and Further Dependencies.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
Computing & Information Sciences Kansas State University Friday, 03 Oct 2007CIS 560: Database System Concepts Lecture 16 of 42 Wednesday, 03 October 2007.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
Normal Forms Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems June 18, 2016 Some slide content courtesy of Susan Davidson.
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.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Advanced Normalization
Database Design Dr. M.E. Fayad, Professor
Relational Database Design by Dr. S. Sridhar, Ph. D
Advanced Normalization
Database Design Dr. M.E. Fayad, Professor
Chapter 7a: Overview of Database Design -- Normalization
Presentation transcript:

Chapter 8 Relational Database Design

2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize anomaly problems (data model is structured in an improper manner) n Maintain (correct) information n Enforce semantic and integrity constraints, e.g., using dependency and domain constraints

3 Relational Database Design: Problems n Data replication: extra storage, update anomalies n Anomaly: costly and data inconsistency n Loss of information: lossy decomposition n Un-enforced dependency constraints: dependencies are lost

4 Integrity Constraints: Functional Dependency (FD)  FD constraints derived from the intra-relationships among attributes in a relation that models the real-world enterprise  Used to specify integrity/semantic constraints of legal relations  Definition: Let X  R and Y  R. ● X  Y, i.e., X functionally determines Y iff  t 1, t 2  r(R), t 1 [X] = t 2 [X]  t 1 [Y] = t 2 [Y] ● A set of attributes X functionally determines a set of attributes Y if the value of X uniquely determines the value of Y ● If X  R, then X is a superkey of R, i.e.,  t 1, t 2  r(R), t 1 [X] = t 2 [X]  t 1 [R] = t 2 [R], which holds for all instances of R ● Total # of possible FDs in R: 2 |R|  2 |R| including   R, R   ● Trivial FDs: FDs satisfied by all relations, e.g., R  A since t 1 [R] = t 2 [R]  t 1 [A] = t 2 [A] (general from) X  Y is trivial if Y  X ● A schema constraint instead of an instance constraint

5 Integrity Constraints n Inference Rules for FDs n Determines FDs that are logically implied by a set of FDs, e.g., if A  B and B  C, then A  C, since by definition if t 1 [A] = t 2 [A], then t 1 [B] = t 2 [B], and if t 1 [B] = t 2 [B], then t 1 [C] = t 2 [C] implies if t 1 [A] = t 2 [A], then t 1 [C] = t 2 [C] ● Closure of a set of FDs, F, is the set F + of all FDs that can be inferred from (or implied by) F ● Given a set of FDs, F, inferred FDs hold whenever the FDs in F hold, e.g., X  AB  X  A and X  B ● Determine all the FDs of F + : use Armstrong’s axioms

6 Integrity Constraints n Armstrong’s Axioms (AA). Let , , ,  be sets of attributes  A1. Reflexivity: If   , then     A2. Augmentation: If   , then     A3. Transitivity: If    and   , then    n AA is sound: If    is inferred from a set of FDs F using AA, then    holds in any relation in which FDs in F hold n AA is complete: it generates all the FDs in F + n Additional inference rules follow from AA:  A4. Union: If    and   , then     A5. Decomposition: If   , then    and     A6. Pseudotransitivity: If    and   , then   

7 Integrity Constraints n Closure of attribute sets  Closure of a set of attributes  with respect to F is the set  + of all attributes that are functionally determined by    + can be calculated by applying AA repeatedly using the FDs in F  Algorithm  Algorithm: Compute the closure of a set of attrs. Input Input: A set of attributes, , and a set of FDs, F. Output Output: The closure of ,  + (i.e.,  ). BEGIN  :=  ; REPEAT for each FD     F do if    then  :=    ; UNTIL there are no changes to  END;

8 Key Finding Algorithm Algorithm: Determine all (candidate) keys for a relation schema. Input Input: A set of FDs, F, and a relation schema, R. Output Output: The set of keys for R.BEGIN Remark 1. If an attribute A appears only on the left hand side (L.H.S.) of the FDs in F, then attribute A has to be in all keys because it cannot be inferred. Remark 2. If an attribute A appears only on the right hand side (R.H.S.) of the FDs in F, then it is highly unlikely (unless in a very special circumstance) that A is an attribute in a key. Step 1. Determine those attributes that appear only on the L.H.S. of the FDs in F. This set of attributes, called X, must be in all keys. Step 2. Determine whether X in Step 1 is a key. If so, X is the only key. If not, start adding attributes (one at a time) that appear on both L.H.S. and R.H.S. of the FDs in F to X. Step 3. If Step 2 fails to find a key, then add attributes (one at a time) which appear only on the R.H.S. of the FDs in F to X.END

9 Relational Database Design n Normalization  A DB schema design tool  A process of replacing associations among attributes in a relation schema  An approximation of the relation schemas that should be created  Objectives: accomplish the goals of relational DB design  2 approaches: decomposition and synthesis

10 Relational Database Design n Decomposition  A process to split or decompose a relation until the resultant relations no longer exhibit the undesirable problems, e.g., data redundancy, data inconsistency, anomaly, etc.  Decomposing a relation schema R means breaking R into a pair of schemas, possibly intersecting this process is repeated until all the decomposed relation schemas are in the desired (normal) form.

11 Relational Database Design Normal Forms (NFs) n Restrictions on the DB schema that preclude certain undesirable properties (data redundancy, update anomaly, loss of information, etc.) from the DB. n A relation schema R is in PJNF if R is in 4NF if R is in BCNF if R is in 3NF if R is in 2NF if R is in 1NF 1NF 2NF 3NF BCNF 4NF PJNF

12 Relational Database Design Normal Forms (NFs) n Definition. A data value v is atomic if v is not (i) a set of values or (ii) composite value; otherwise, v is non-atomic. n First Normal Form (1NF). A relation schema R is in 1NF if for every attribute A in R, the values in the domain of A, i.e., dom(A), are atomic. n Boyce-Codd Normal Form (BCNF). A relation schema R is in BCNF if for every non-trivial FD X  Y applied to R, X is a superkey for R. n Definition. Let A be an attribute in a relation schema R, and let F be a set of FDs over R. A is a prime attribute in R if A is contained in some candidate key of R; otherwise, A is a non-prime attribute in R.

13 Relational Database Design Normal Forms (NFs) n Third Normal Form (3NF). A relation schema R is in 3NF if 1 R is in 1NF, and 2 For every non-trivial FD X  Y applied to R, either – X is a superkey for R, or – every attribute in Y is an attribute of some candidate key for R, i.e., prime. n Lossy decomposition: a decomposition is lossy if the natural join of all the decomposed relations contain additional tuples and the original relation is lost. n Lossless decomposition: a decomposition is lossless if the natural join of all the decomposed relations always yields the original relation without any extra tuples, i.e., a decomposition {R 1, R 2, …, R n } of R is lossless if  r(R), r(R) =  R 1 (r)   R 2 (r)  …   R n (r)

14 Relational Database Design n 2-Relational lossless-join decomposition: Let R 1 and R 2 be decomposed schemas of R. Let F be a set of FDs on R. The decomposition is lossless if R 1  R 2  R 1  F + or R 1  R 2  R 2  F + n Dependency preserving: a decomposition is dependency preserving if no dependency is lost in the process. Let F be the set of FDs on R. Let R 1, …, R n be a decomposition of R. Let F i, 1  i  n, be the set of FDs in F + which applies to R i. Let F’ =  i = 1..n F i. If F’ + = F +, then the decomposition is dependency preserving.