Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.

Slides:



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

Manipulating Functional Dependencies Zaki Malik September 30, 2008.
Chapter 11 Functional Dependencies. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.11-2 Topics in this Chapter Basic Definitions Trivial.
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.
Temple University – CIS Dept. CIS616– Principles of Data Management V. Megalooikonomou Functional Dependencies (based on notes by Silberchatz,Korth, and.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
Properties of Armstrong’s Axioms Soundness All dependencies generated by the Axioms are correct Completeness Repeatedly applying these rules can generate.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications Lecture #16: Schema Refinement & Normalization - Functional Dependencies.
Functional Dependencies - Example
Topics to be discusses Functional Dependency Key
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 227 Database Systems I Design Theory for Relational Databases.
Multivalued Dependency Prepared by Tomasz Kaciak CS157A.
FDImplication: 1 Functional Dependencies (FDs) Let r(R) be a relation and let t  r, then the restriction of t to X  R, written t[X], is the projection.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
DATABASE DESIGN Functional Dependencies. Overview n Functional Dependencies n Normalization –Functional dependencies –Normal forms.
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 9.
Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Cs3431 Normalization. cs3431 Why Normalization? To remove potential redundancy in design Redundancy causes several anomalies: insert, delete and update.
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C3.
Boyce-Codd NF & Lossless Decomposition Professor Sin-Min Lee.
Fall 2001Arthur Keller – CS 1804–1 Schedule Today Oct. 4 (TH) Functional Dependencies and Normalization. u Read Sections Project Part 1 due. Oct.
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.
Functional Dependencies Prof. Yin-Fu Huang CSIE, NYUST Chapter 11.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Computing & Information Sciences Kansas State University Monday, 13 Oct 2008CIS 560: Database System Concepts Lecture 18 of 42 Monday, 13 October 2008.
Multi-valued Dependencies and Fourth Normal Form
Lecture 09: Functional Dependencies. Outline Functional dependencies (3.4) Rules about FDs (3.5) Design of a Relational schema (3.6)
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Relational.
Functional Dependencies An example: loan-info= Observe: tuples with the same value for lno will always have the same value for amt We write: lno  amt.
Computing & Information Sciences Kansas State University Tuesday, 27 Feb 2007CIS 560: Database System Concepts Lecture 18 of 42 Tuesday, 27 February 2007.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 10 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.
1 Lecture 6: Schema refinement: Functional dependencies
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.
Christoph F. Eick: Functional Dependencies, BCNF, and Normalization 1 Functional Dependencies, BCNF and Normalization.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Minimum Cover of F. Minimal Cover for a Set of FDs Minimal cover G for a set of FDs F: –Closure of F = closure of G. –Right hand side of each FD in G.
Deanship of Distance Learning Avicenna Center for E-Learning 1 Session - 7 Sequence - 2 Normalization Functional Dependencies Presented by: Dr. Samir Tartir.
1 Functional Dependencies. 2 Motivation v E/R  Relational translation problems : –Often discover more “detailed” constraints after translation (upcoming.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications Lecture #16: Schema Refinement & Normalization - Functional Dependencies.
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.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Multivalued Dependencies and 4th NF CIS 4301 Lecture Notes Lecture /21/2006.
CS 222 Database Management System Spring Lecture 4 Database Design Theory Korra Sathya Babu Department of Computer Science NIT Rourkela.
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
CS411 Database Systems Kazuhiro Minami 04: Relational Schema Design.
Databases 1 Sixth lecture. 2 Functional Dependencies X -> A is an assertion about a relation R that whenever two tuples of R agree on all the attributes.
© 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.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
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.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Normalization Functional Dependencies Presented by: Dr. Samir Tartir
3.1 Functional Dependencies
Schema Refinement & Normalization Theory
Functional Dependencies and Normalization
Functional Dependencies
Normalization cs3431.
Chapter 19 (part 1) Functional Dependencies
Functional Dependencies
Presentation transcript:

Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006

Lecture 8© CIS Spring Definition Functional Dependency (FD) Formally: A 1, A 2, …, A n  B (commas usually omitted) Read: “A 1, A 2, …, A n functionally determine B” If two tuples of r(R) agree on attributes A 1, A 2, …, A n of R, then they must also agree in another attribute B i.e., the tuples have the same values in their respective components for each of these attributes Also, if A 1 A 2 … A n  B 1 A 1 A 2 … A n  B 2 …… A 1 A 2 … A n  B m then A 1 A 2 … A n  B 1 B 2 … B m

Lecture 8© CIS Spring Rules About Functional Dependencies Let F be set of FDs specified on R Must be able to reason about FD’s in F Designer usually explicitly states only FD’s which are obvious Without knowing exactly what all tuples are, must be able to deduce other/all FD’s that hold on R Essential when we discuss design of “good” relational schemas

Lecture 8© CIS Spring Example Relation R with attributes A, B, C Assume R satisfies FD’s A  B and B  C How can we deduce that A  C? Use definition, namely show that if two random tuples agree on A they must also agree on C

Lecture 8© CIS Spring More Definitions Two sets of FD’s S and T are equivalent if the set of relation instances satisfying S is exactly the same as the set satisfying T More general: set of FD’s S follows from set of FD’s T if every relation instance satisfying all FD’s in T also satisfies all the FD’s in S S equivalent to T iff S follows from T and T follows from S

Lecture 8© CIS Spring Trivial Dependencies A functional dependency A 1 A 2 …A n  B is said to be trivial if B is one of the A’s Ex.: title year  title Every trivial dependency holds in every relation i.e., tuples that agree in all of A 1,A 2, …, A n agree in one of them We may assume trivial dependencies without having to justify them trivial: B’s subset of A’s nontrivial: at least one of the B’s not among A’s completely nontrivial: none of the B’s part of A’s

Lecture 8© CIS Spring Rules About Functional Dependencies SPLITTING RULE: If AA  B 1, B 2,..., B n then AA  B 1, AA  B 2,..., AA  B n Q: Can we also split the left-hand side? COMBINING RULE: If AA  B 1, AA  B 2,..., AA  B n then AA  B 1, B 2,..., B n TRIVIAL DEPENDENCY RULES: If AA  BB then AA  (BB - AA) If AA  BB then AA  (BB  AA) TRANSITIVE RULE: If AA  BB and BB  CC then AA  CC

Lecture 8© CIS Spring Example: Transitivity Rule R(A,B,C) F: A  B, B  C Show A  C holds? Show that two tuples in r(R) that agree on A also agree on C Step 1: t=(a,b 1,c 1 ), u=(a,b 2,c 2 ) Step 2: Since A  B, and tuples agree on A, they must also agree on B  b 1 = b 2  t = (a,b,c 1 ), u = (a,b,c 2 )

Lecture 8© CIS Spring Example Cont’d Step 3: Since B  C and tuples agree on B, must also agree on C  c 1 = c 2  t = (a,b,c), u = (a,b,c) Step 4:  tuples that agree on A also agree on C  A  C

Lecture 8© CIS Spring Closure of Attributes General principle from which all rules follow Given a relation R, a set of FD's for R, and a set of attributes {A 1, A 2,..., A m } of R: Find all attributes B such that A 1, A 2,..., A m  B follows from the FD’s of R This set of attributes is called the "closure" and is denoted {A 1, A 2,..., A m } +

Lecture 8© CIS Spring Algorithm for Computing Closure Start with {A1, A2,..., Am} repeat until no change: if current set of attributes includes LHS of a dependency, add RHS attributes to the set ** Effectively applies combining and transitive rules until there's no more change

Lecture 8© CIS Spring Calculating the Closure R=(A,B,C,D,E,F) F: AB  C, BC  AD, D  E, CE  B How to compute closure of {A,B}, i.e., {A,B} + ? 1. Start with X={A,B} 2. Add C to X due to AB  C; X={A,B,C} 3. Add A,D to X due to BC  AD; X={A,B,C,D} 4. Add E to X due to D  E; X={A,B,C,D,E} 5. No more attributes can be added to X 6. {A,B} + = {A,B,C,D,E}

Lecture 8© CIS Spring So What! If we can compute closure of any set of attributes, we can test whether any given functional dependency A 1 A 2 …A n  B follows from set of dependencies F Compute closure of {A 1, A 2, …, A n } + using F If B is in {A 1, A 2, …, A n } +, then A 1 A 2 …A n  B does follow from F ALSO: We can test if K={A 1,A 2,…,A n } is a key for relation R if {A 1,A 2,…,A n } + is the set of all attributes in R and if K is minimal

Lecture 8© CIS Spring Closing Sets of FD's Let F be set of FDs specified on R Must be able to reason about FD’s in F Designer usually explicitly states only FD’s which are obvious (given FD’s) Without knowing exactly what all tuples are, must be able to deduce other FD’s that hold on R (derived FD’s) Essential when we discuss design of “good” relational schemas Any set of FD’s from which we can infer full set of FD’s for relation is called basis for that relation Minimal basis

Lecture 8© CIS Spring Exercise Consider a relation with schema R(A, B,C, D) and functional dependencies F: AB  C, C  D, and D  A. a) What are all the non-trivial FD’s that follow from the given dependencies? b) What are the keys of R? c) What are all the superkeys for R that are not keys?

Lecture 8© CIS Spring Projecting Functional Dependencies Given relation R and set of FD’s F that hold on R Suppose we have new relation S that has subset of attributes of relation R What FD’s hold on S? Compute all FD’s that follow from F AND involve only attributes of S Use closure of all subsets of attributes in S Can use some observations: Closing empty set and complete set will no yield a nontrivial FD If we know the closure of some set X is all attributes, then closing supersets of X will not yield any new FD’s

Lecture 8© CIS Spring Set of Inference Rules Reflexive rule Augmentation rule Transitivity rule Decomposition rule Union rule Pseudotransitive rule Armstrong’s axioms: sound and complete

Lecture 8© CIS Spring Final Thought How can we tell if one FD follows from others? Use Armstrong’s axioms and reason it out, OR Attribute closure algorithm always works