ICS 321 Fall 2011 Functional Dependencies Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 09/07/20111Lipyeow.

Slides:



Advertisements
Similar presentations
Schema Refinement and Normal Forms. 421B: Database Systems - Functional Dependencies 2 Why schema refinement? q Consider relation obtained from Hourly_Emps:
Advertisements

primary key constraint foreign key constraint
Schema Refinement and Normal Forms
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
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.
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.
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.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications Lecture #16: Schema Refinement & Normalization - Functional Dependencies.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 227 Database Systems I Design Theory for Relational Databases.
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.
Cs3431 Normalization. cs3431 Why Normalization? To remove potential redundancy in design Redundancy causes several anomalies: insert, delete and update.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
1 Schema Refinement and Normal Forms Yanlei Diao UMass Amherst April 10, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Functional Dependencies CS 186, Spring 2006, Lecture 21 R&G Chapter 19 Science is the knowledge of consequences, and dependence of one fact upon another.
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.
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.
Schema Refinement and Normal Forms Chapter 19 1 Database Management Systems 3ed, R.Ramakrishnan & J.Gehrke.
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
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.
Database Systems/COMP4910/Spring02/Melikyan1 Schema Refinement and Normal Forms.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
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:
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Schema Refinement SHIRAJ MOHAMED M | MIS 1. Learning Objectives  Identify update, insertion and deletion anomalies  Identify possible keys given an.
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.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 15.
Functional Dependencies R&G Chapter 19 Science is the knowledge of consequences, and dependence of one fact upon another. Thomas Hobbes ( )
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
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.
ICS 421 Spring 2010 Relational Model & Normal Forms Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1/19/20101Lipyeow.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
CS 222 Database Management System Spring Lecture 4 Database Design Theory Korra Sathya Babu Department of Computer Science NIT Rourkela.
1 Schema Refinement and Normal Forms Chapter The Evils of Redundancy  Redundancy is at the root of several problems associated with relational.
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
CS411 Database Systems Kazuhiro Minami 04: Relational Schema Design.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
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.
Functional Dependencies and Normalization for Relational Databases 1 Chapter 15 تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
1 CS122A: Introduction to Data Management Lecture #12: Relational DB Design Theory (1) Instructor: Chen Li.
Functional Dependencies, BCNF and Normalization
Schema Refinement & Normalization Theory
Functional Dependencies
Functional Dependencies
Normalization cs3431.
Chapter 19 (part 1) Functional Dependencies
Presentation transcript:

ICS 321 Fall 2011 Functional Dependencies Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 09/07/20111Lipyeow Lim -- University of Hawaii at Manoa

Example: Movies1 What are the keys for this relational ? What if you ignore the column starName ? Can starName be a key ? 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa2

Functional Dependency A functional dependency X -> Y holds over relation R if, for every allowable instance r of R: – for all tuples t1,t2 in r, π X (t1) = π X (t2) implies π Y (t1) = π Y (t2) – i.e., given two tuples in r, if the X values agree, then the Y values must also agree. (X and Y are sets of attributes.) An FD is a statement about all allowable instances. – Must be identified based on semantics of application. – Given some allowable instance r1 of R, we can check if it violates some FD f, but we cannot tell if f holds over R! K is a candidate key for R means that K -> R – However, K -> R does not require K to be minimal! 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa3

Keys & Superkeys A set of one or more attributes {A 1, A 2,... A n } is a key for a relation R if : – 1. Those attributes functionally determine all other attributes of the relation. – 2. No proper subset of {A 1, A 2,... A n } functionally determines all other attributes of R a key must be minimal. When a key consists of a single attribute A, we often say that A ( rather than {A} ) is a key. Superkey : a set of attributes that contain a key. 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa4

FD Example: Movies1 What are the FDs for this relation ? What are the keys for this relation ? Can starName be a key ? 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa5

Reasoning about FDs Given some FDs, we can usually infer additional FDs: – ssn -> deptID, deptID -> building implies ssn -> building T implies S, or S follows from T – Every relation instance that satisfies all the FDs in T also satisfies all the FDs in S S is equivalent to T – The set of relation instances satisfying S is exactly the same as the set satisfying T – Alternatively, S implies T AND T implies S 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa6

Armstrong’s Axioms Let X, Y, Z are sets of attributes: Reflexivity – If X is a subset of Y, then Y -> X Augmentation – If X -> Y, then XZ -> YZ for any Z Transitivity – If X -> Y and Y -> Z, then X -> Z These are sound and complete inference rules for FDs! 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa7

Example: Armstrong’s Axioms Reflexivity: If X is a subset of Y, then Y -> X – SNLR is a subset of SNLRWH, SNLRWH -> SNLR Augmentation: If X -> Y, then XZ -> YZ for any Z – S -> N, then SLR -> NLR Transitivity: If X -> Y and Y -> Z, then X -> Z – S -> R, R -> W, then S -> W 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa8 Hourly_Emps SSNNameLotRatingHourly_WagesHours_worked Attishoo Smiley Smethurst Guldu Madayan

Two More Rules Union / Combining – If X  Y and X  Z, then X  YZ – Eg. FLD  A and FLD  T, then FLD  AT Decomposition / Splitting – If X  YZ, then X  Y and X  Z – Eg. FLD  AT, then FLD  A and FLD  T Trivial FDs – Right side is a subset of Left side – Eg. F  F, FLD  FD Does “XY  Z imply X  Z and Y  Z” ? 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa9 FirstnameLastnameDOBAddressTelephone JohnSmithSep Honolulu,HI

Closure Implication: An FD f is implied by a set of FDs F if f holds whenever all FDs in F hold. – f=A  C is implied by F={ A  B, B  C} (using Armstrong’s transitivity) Closure F + : the set of all FDs implied by F – Algorithm: start with F + =F keep adding new implied FDs to F + by applying the 5 rules ( Armstrong’s Axioms + union + decomposition) Stop when F + does not change anymore. 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa10

Example: Closure Given FLD is the primary key and C  Z Find the closure: – Start with { FLD  FLDSCZT, C  Z } – Applying reflexivity, { FLD  F, FLD  L, FLD  D, FLD  FL, FLD  LD, FLD  DF, FLDSCZT  FLD, …} – Applying augmentation, { FLDS  FS, FLDS  LS, …} – Applying transitivity … – Applying union … – Applying decomposition … – Repeat until F + does not change 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa11 FirstnameLastnameDOBStreetCityStateZipcodeTelephone JohnSmithSep East West Rd. Honolulu,HI

Attribute Closure Computing the closure of a set of FDs can be expensive. (Size of closure is exponential in # attrs!) Typically, we just want to check if a given FD X  Y is in the closure of a set of FDs F. An efficient check: – Compute attribute closure of X (denoted X + ) wrt F: Set of all attributes A such that X  A is in F + There is a linear time algorithm to compute this. – Check if Y is in X + Does F = {A  B, B  C, C D  E } imply A  E? – i.e, is A  E in the closure F + ? Equivalently, is E in A + ? 09/07/2011Lipyeow Lim -- University of Hawaii at Manoa12