Functional Dependency

Slides:



Advertisements
Similar presentations
Higher Normal Forms By John Nicosia CS 157a Fall 2007.
Advertisements

primary key constraint foreign key constraint
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
Functional Dependencies and Normalization for Relational Databases.
Multivalued Dependency Prepared by Tomasz Kaciak CS157A.
Functional Dependency Rajhdeep Jandir. Definition A functional dependency is defined as a constraint between two sets of attributes in a relation from.
Functional Dependencies (Part 3) Presented by Nash Raghavan All page numbers are in reference to Database System Concepts (5 th Edition)
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Your name here. Improving Schemas and Normalization What are redundancies and anomalies? What are functional dependencies and how are they related to.
DatabaseIM ISU1 Chapter 10 Functional Dependencies and Normalization for RDBs Fundamentals of Database Systems.
Normalization Ioan Despi 2 The basic objective of logical modeling: to develop a “good” description of the data, its relationships and its constraints.
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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Deanship of Distance Learning Avicenna Center for E-Learning 1 Session - 7 Sequence - 2 Normalization Functional Dependencies Presented by: Dr. Samir Tartir.
Chapter 5.1 and 5.2 Brian Cobarrubia Database Management Systems II January 31, 2008.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
CS411 Database Systems Kazuhiro Minami 04: Relational Schema Design.
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) هي وسيلة لتوضيح الدرس واداة من الادوات في.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
1 Normalization Theory. 2 Limitations of E-R Designs Provides a set of guidelines, does not result in a unique database schema Does not provide a way.
10/3/2017.
10/3/2017.
4TH NORMAL FORM By: Karen McVay.
Normalization Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 19.
Functional Dependency and Normalization
Advanced Normalization
Chapter 15 Relational Design Algorithms and Further Dependencies
Normalization DBMS.
Functional Dependencies and Normalization for Relational Databases
A brief summary of database normalization
Database Management Systems (CS 564)
Normalization Functional Dependencies Presented by: Dr. Samir Tartir
Module 5: Overview of Database Design -- Normalization
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Database Design Dr. M.E. Fayad, Professor
Relational Database Design by Dr. S. Sridhar, Ph. D
Handout 4 Functional Dependencies
Advanced Normalization
Functional Dependency & Normalization
Relational Design Theory
Functional Dependencies and Normalization for Relational Databases
Database Management systems Subject Code: 10CS54 Prepared By:
Database Normalization
Module 5: Overview of Normalization
Schema Refinement What and why
Normalization Murali Mani.
Functional Dependencies and Normalization
Normalization.
Normalization cs3431.
CS 405G: Introduction to Database Systems
Instructor: Mohamed Eltabakh
Schema Refinement and Normal Forms
Lecture 5: Functional dependencies and normalization
Relational Database Design
Relational Database Theory
CSC 453 Database Systems Lecture
Database Design Dr. M.E. Fayad, Professor
Chapter 7a: Overview of Database Design -- Normalization
Functional Dependencies and Normalization
Presentation transcript:

Functional Dependency

Definition A functional dependency is defined as a constraint between two sets of attributes in a relation from a database. Given a relation R, a set of attributes X in R is said to functionally determine another attribute Y, also in R, (written X → Y) if and only if each X value is associated with at most one Y value.

In other words…. X is the determinant set and Y is the dependent attribute. Thus, given a tuple and the values of the attributes in X, one can determine the corresponding value of the Y attribute.

Example Employee SSN Name JobType DeptName 557-78-6587 Lance Smith Accountant Salary 214-45-2398 Engineer Product Note: Name is functionally dependent on SSN because an employee’s name can be uniquely determined from their SSN. Name does not determine SSN, because more than one employee can have the same name..

Keys Whereas a key is a set of attributes that uniquely identifies an entire tuple, a functional dependency allows us to express constraints that uniquely identify the values of certain attributes. However, a candidate key is always a determinant, but a determinant doesn’t need to be a key.

Closure Let a relation R have some functional dependencies F specified. The closure of F (usually written as F+) is the set of all functional dependencies that may be logically derived from F. Often F is the set of most obvious and important functional dependencies and F+, the closure, is the set of all the functional dependencies including F and those that can be deduced from F. The closure is important and may, for example, be needed in finding one or more candidate keys of the relation.

Example Student SNo SName CNo CName Addr Instr. Office 5425 Susan Ross 102 Calc I …San Jose, CA P. Smith B42 Room 112 7845 Dave Turco 541 Bio 10 ...San Diego, CA L. Talip B24 Room 210 SNo -> SName CNo -> CName Instr -> Office SNo -> Addr CNo -> Instr

Axioms Before we can determine the closure of the relation, Student, we need a set of rules. Developed by Armstrong in 1974, there are six rules (axioms) that all possible functional dependencies may be derived from them.

Axioms Cont. 1. Reflexivity Rule --- If X is a set of attributes and Y is a subset of X, then X  Y holds. each subset of X is functionally dependent on X. 2. Augmentation Rule --- If X  Y holds and W is a set of attributes, then WX  WY holds. 3. Transitivity Rule --- If X  Y and Y  Z holds, then X  Z holds.

Derived Theorems from Axioms 4. Union Rule --- If X  Y and X  Z holds, then X  YZ holds. 5. Decomposition Rule --- If X  YZ holds, then so do X  Y and X  Z. 6. Pseudotransitivity Rule --- If X  Y and WY  Z hold then so does WX  Z.

Back to the Example SNo SName CNo CName Addr Instr. Office Based on the rules provided, the following dependencies can be derived. (SNo, CNo)  SNo (Rule 1) -- subset (SNo, CNo)  CNo (Rule 1) (SNo, CNo)  (SName, CName) (Rule 2) -- augmentation CNo  office (Rule 3) -- transitivity SNo  (SName, address) (Union Rule) etc.

Too Many FDs Using the first rule alone, from our example we have 2^7 = 128 subsets. This will further lead to many more functional dependencies. This defeats the purpose of normalizing relations. So what now? One way is to deal with one attribute or a set of attributes at a time and find its closure (i.e. all functional dependencies relating to them). The aim of this exercise is to find what attributes depend on a given set of attributes and therefore ought to be together.

The approach Step 1 Let X^c <- X Step 2 Let the next dependency be A -> B. If A is in X^c and B is not, X^c <- X^c + B. Step 3 Continue step 2 until no new attributes can be added to X^c.

Back To Our Example Consider the following relation: student(SNo, SName, CNo, CName). We wish to determine the closure of (SNo, CNo). We have the following functional dependencies. SNo -> SName CNo -> CName Step 1 --- X^c <- X, that is, X^c <- (SNo, CNo) Step 2 --- Consider SNo -> SName, since SNo is in X^c and SName is not, we have: X^c <- (SNo, CNo) + SName Step 3 --- Consider CNo -> CName, since CNo is in X^c and CName is not, we have: X^c <- (SNo, CNo, SName) + CName Step 4 --- Again, consider SNo -> SName but this does not change X^c. Step 5 --- Again, consider CNo -> CName but this does not change X^c. Therefore X+ = X^c = (SNo, CNo, SName, CName). This shows that all the attributes in the relation student (SNo, CNo, SName, CName) are dependent on (SNo, CNo) and therefore (SNo, CNo) is a candidate key of the present relation. In this case, it is the only candidate key.

Normal Form Initially Codd (1972) presented three normal forms (1NF, 2NF and 3NF) all based on functional dependencies among the attributes of a relation. Later Boyce and Codd proposed another normal form called the Boyce-Codd normal form (BCNF). The fourth and fifth normal forms are based on multi-value and join dependencies and were proposed later. The primary objective of normalization is to avoid anomalies.