Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.

Slides:



Advertisements
Similar presentations
ICS 321 Fall 2011 Functional Dependencies Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 09/07/20111Lipyeow.
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.
1 Design Theory. 2 Minimal Sets of Dependancies A set of dependencies is minimal if: 1.Every right side is a single attribute 2.For no X  A in F and.
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.
Database Management Systems Chapter 3 The Relational Data Model (II) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
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.
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
Functional Dependencies Definition: If two tuples agree on the attributes A, A, … A 12n then they must also agree on the attributes B, B, … B 12m Formally:
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.
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.
Introduction to Normalization CPSC 356 Database Ellen Walker Hiram College.
Database Systems Normal Forms. Decomposition Suppose we have a relation R[U] with a schema U={A 1,…,A n } – A decomposition of U is a set of schemas.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
Your name here. Improving Schemas and Normalization What are redundancies and anomalies? What are functional dependencies and how are they related to.
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.
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.
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.
Functional Dependencies. Outline Functional dependencies (3.4) Rules about FDs (3.5) Design of a Relational schema (3.6)
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.
© D. Wong Ch. 3 (continued)  Database design problems  Functional Dependency  Keys of relations  Decompositions based on Functional Dependency.
Deanship of Distance Learning Avicenna Center for E-Learning 1 Session - 7 Sequence - 2 Normalization Functional Dependencies Presented by: Dr. Samir Tartir.
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.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
Functional dependencies CMSC 461 Michael Wilson. Designing tables  Now we have all the tools to build our databases  How should we actually go about.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
Functional Dependencies Zaki Malik September 25, 2008.
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.
11/06/97J-1 Principles of Relational Design Chapter 12.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
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.
Formal definition of a key A key is a set of attributes A 1,..., A n such that for any other attribute B: A 1,..., A n  B A minimal key is a set of attributes.
Functional Dependency
Normalization Functional Dependencies Presented by: Dr. Samir Tartir
3.1 Functional Dependencies
Functional Dependencies
Normalization cs3431.
Chapter 3: Design theory for relational Databases
Presentation transcript:

Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.

 A functional dependency on relation R is a logical expression of the form X  Y  X and Y are sets of attributes of R ▪ i.e. X = { A 1, A 2,..., A n } and Y = { B 1, B 2,..., B m } where n = m or n <> m  X  Y means that whenever any pair of tuples in R have the same values for attributes in X, then they must also have the same values for attributes in Y

 For each X  Y defined on relation R, it means that X functionally determines Y  Or more specifically, the attributes of X functionally determine the attributes of Y  More generally, a functional dependency adds meaning to attributes of R  In some cases, the occurrence of duplicate tuples does not make semantic sense

 For a given relation R, we look at the set of all functional dependencies to tell us what tuples we can (and should) store  We can also reason by applying simple inference rules to the tuples  e.g. transitivity, splitting/combining, etc.

 A constraint of any kind on relation R is said to be trivial if it holds for every instance of R  If Y  X, then X  Y is true for all relations  In other words, a trivial functional dependency has a right-hand side (Y) that is a subset of its left-hand side (X)  e.g. name artist  name  e.g. name  name What’s the point? We can remove trivial FDs! Reflexivity rule

 The functional dependency X  Y is equivalent to X  Z where attributes of Z are all those attributes of Y that are not also attributes of X  In other words, some of the attributes on the right-hand side (of X  Y) are also on the left (X)  We can simplify this by removing attributes from the right-hand side that also appear on the left

 Given functional dependency  X  Y  We can always add a set Z of attribute(s)  XZ  YZ  This is called augmentation

 Given functional dependency X  Y as  A 1, A 2,..., A n  B 1, B 2,..., B m  We can split it into multiple functional dependencies (singletons) as follows:  A 1, A 2,..., A n  B 1  A 1, A 2,..., A n  B 2 ...  A 1, A 2,..., A n  B m

 Given functional dependencies as follows:  A 1, A 2,..., A n  B 1  A 1, A 2,..., A n  B 2 ...  A 1, A 2,..., A n  B m  We can combine attributes on the right- hand side to form functional dependency  A 1, A 2,..., A n  B 1, B 2,..., B m

 Given functional dependencies  X  Y and Y  Z  We can unequivocally conclude that  X  Z  And if some attributes of Z are also attributes of X, we can eliminate them from the right-hand side (trivial-dependency rule)

 For a given relation R, we look at the set of functional dependencies to identify which attribute(s) imply all the rest  These attribute(s) form a key on R  Set K = { A 1, A 2,..., A n } is a key on R if:  K functionally determine all other attributes of R  No proper subset of K functionally determines all other attributes of R

 By definition, a key must be unique  A key K must functionally determine all other attributes of relation R  e.g. Student( id, name, address )  The key is the id attribute

 By definition, a key must be minimal  No proper subset of key K can functionally determine all other attributes of relation R  e.g. Student( id, name, address )  Even though id and name together might be unique, the id attribute is minimal

 A set of attributes that contains a key is called a superkey (a superset of a key)  The uniqueness constraint must be satisfied  The minimality constraint need not be satisfied  Every key is a superkey  e.g. Student( id, name, address )  Attribute id is both a key and a superkey  Attributes (id, name) form a superkey

 Model a US Census relation  Name, SSN, address, city, state, zip, area code, phone number, etc.  Use only a single relation  Describe functional dependencies  Identify keys and superkeys

 Given relation R with attributes A, B, C, D, E and A  BC, CD  E, BE  C  What does AE functionally determine (infer)?  In other words, AE  _____?

 Given a set of attributes X, the closure X+ is the set of attributes functionally determined by X  Given a relation R and a set F of functional dependencies, we need a way to find whether a functional dependency X  Y is true with respect to F

 Given relation R with attributes A, B, C, D, E and A  BC, CD  E, BE  C  AE  _____?  From reflexivity, AE+ = { A, E }  From A  BC, AE+ = { A, B, C, E }  No other rules are applicable or add to AE+  We conclude that AE  ABCE or simply AE  BC  Or AE  A, AE  B, AE  C, and AE  E

 Given a set F of functional dependencies, the closure X+ of a set of attributes X is determined by the following algorithm:  Initialize X+ to X  Repeat until X+ does not change: ▪ Find any unapplied functional dependency Y  Z in F such that Y  X+ ▪ Set X+ = X+  Z

 A set F of functional dependencies implies a functional dependency X  Y if Y  X+  In other words, if Y is in the closure of X, then functional dependency X  Y is true

 A key K for a given relation R is a minimal set of attributes A 1, A 2,..., A n such that closure {A 1, A 2,..., A n }+ is the set of all attributes of R  MusicGroup(name, artist, genre, dateformed, datefirstjoined)  name  genre dateformed  name artist  datefirstjoined  K must be (name, artist) because K+ = {name, artist, genre, dateformed, datefirstjoined}

 Review the US Census relation  What other functional dependencies can you infer?  Pick pairs of attributes (e.g. name and state) and identify the resulting closure  In other words, what is the set of attributes X+ functionally determined by set X (the pair)?