Functional Dependencies & Normalization. Dr. Bassam Hammo

Similar documents
Functional Dependencies

Relational Database Design

Schema Refinement and Normal Forms. Chapter 19

UVA UVA UVA UVA. Database Design. Relational Database Design. Functional Dependency. Loss of Information

Constraints: Functional Dependencies

Constraints: Functional Dependencies

CAS CS 460/660 Introduction to Database Systems. Functional Dependencies and Normal Forms 1.1

Schema Refinement & Normalization Theory: Functional Dependencies INFS-614 INFS614, GMU 1

Schema Refinement & Normalization Theory

CSC 261/461 Database Systems Lecture 10 (part 2) Spring 2018

Schema Refinement and Normal Forms. The Evils of Redundancy. Schema Refinement. Yanlei Diao UMass Amherst April 10, 2007

Introduction to Data Management. Lecture #6 (Relational DB Design Theory)

Functional Dependency and Algorithmic Decomposition

Schema Refinement and Normal Forms Chapter 19

Schema Refinement and Normal Forms. Why schema refinement?

Introduction to Data Management. Lecture #6 (Relational Design Theory)

Schema Refinement and Normalization

Schema Refinement: Other Dependencies and Higher Normal Forms

Schema Refinement and Normal Forms

Schema Refinement and Normal Forms

Review: Keys. What is a Functional Dependency? Why use Functional Dependencies? Functional Dependency Properties

The Evils of Redundancy. Schema Refinement and Normal Forms. Example: Constraints on Entity Set. Functional Dependencies (FDs) Example (Contd.

The Evils of Redundancy. Schema Refinement and Normal Forms. Example: Constraints on Entity Set. Functional Dependencies (FDs) Refining an ER Diagram

Schema Refinement. Feb 4, 2010

CSIT5300: Advanced Database Systems

The Evils of Redundancy. Schema Refinement and Normal Forms. Functional Dependencies (FDs) Example: Constraints on Entity Set. Example (Contd.

Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) [R&G] Chapter 19

Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) CIS 330, Spring 2004 Lecture 11 March 2, 2004

The Evils of Redundancy. Schema Refinement and Normalization. Functional Dependencies (FDs) Example: Constraints on Entity Set. Refining an ER Diagram

Functional Dependencies

Schema Refinement and Normal Forms

Normalization. October 5, Chapter 19. CS445 Pacific University 1 10/05/17

CSC 261/461 Database Systems Lecture 8. Spring 2017 MW 3:25 pm 4:40 pm January 18 May 3 Dewey 1101

SCHEMA NORMALIZATION. CS 564- Fall 2015

Functional Dependencies. Getting a good DB design Lisa Ball November 2012

Introduction. Normalization. Example. Redundancy. What problems are caused by redundancy? What are functional dependencies?

Schema Refinement and Normal Forms

Schema Refinement and Normal Forms. Case Study: The Internet Shop. Redundant Storage! Yanlei Diao UMass Amherst November 1 & 6, 2007

Normal Forms. Dr Paolo Guagliardo. University of Edinburgh. Fall 2016

CS54100: Database Systems

Chapter 3 Design Theory for Relational Databases

Lectures 6. Lecture 6: Design Theory

Information Systems (Informationssysteme)

Schema Refinement. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

Design Theory: Functional Dependencies and Normal Forms, Part I Instructor: Shel Finkelstein

Normaliza)on and Func)onal Dependencies

Relational Design Theory

Relational Database Design Theory Part II. Announcements (October 12) Review. CPS 116 Introduction to Database Systems

Plan of the lecture. G53RDB: Theory of Relational Databases Lecture 10. Logical consequence (implication) Implication problem for fds

Databases 2012 Normalization

Functional Dependencies and Normalization. Instructor: Mohamed Eltabakh

Relational Design Theory I. Functional Dependencies: why? Redundancy and Anomalies I. Functional Dependencies

11/1/12. Relational Schema Design. Relational Schema Design. Relational Schema Design. Relational Schema Design (or Logical Design)

Database Design: Normal Forms as Quality Criteria. Functional Dependencies Normal Forms Design and Normal forms

INF1383 -Bancos de Dados

CSC 261/461 Database Systems Lecture 13. Spring 2018

CSE 132B Database Systems Applications

COSC 430 Advanced Database Topics. Lecture 2: Relational Theory Haibo Zhang Computer Science, University of Otago

Relational Design: Characteristics of Well-designed DB

Chapter 7: Relational Database Design

Functional Dependency Theory II. Winter Lecture 21

11/6/11. Relational Schema Design. Relational Schema Design. Relational Schema Design. Relational Schema Design (or Logical Design)

Chapter 7: Relational Database Design. Chapter 7: Relational Database Design

Chapter 8: Relational Database Design

Database Normaliza/on. Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

10/12/10. Outline. Schema Refinements = Normal Forms. First Normal Form (1NF) Data Anomalies. Relational Schema Design

CSE 344 AUGUST 3 RD NORMALIZATION

Design Theory for Relational Databases

Information Systems for Engineers. Exercise 8. ETH Zurich, Fall Semester Hand-out Due

Functional Dependencies. Applied Databases. Not all designs are equally good! An example of the bad design

Lecture 15 10/02/15. CMPSC431W: Database Management Systems. Instructor: Yu- San Lin

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen

CMPS Advanced Database Systems. Dr. Chengwei Lei CEECS California State University, Bakersfield

Functional Dependencies and Normalization

CSE 303: Database. Outline. Lecture 10. First Normal Form (1NF) First Normal Form (1NF) 10/1/2016. Chapter 3: Design Theory of Relational Database

FUNCTIONAL DEPENDENCY THEORY. CS121: Relational Databases Fall 2017 Lecture 19

L13: Normalization. CS3200 Database design (sp18 s2) 2/26/2018

Database Design and Implementation

Design Theory for Relational Databases

CS122A: Introduction to Data Management. Lecture #13: Relational DB Design Theory (II) Instructor: Chen Li

Design theory for relational databases

Background: Functional Dependencies. æ We are always talking about a relation R, with a æxed schema èset of attributesè and a

A few details using Armstrong s axioms. Supplement to Normalization Lecture Lois Delcambre

CSE 344 MAY 16 TH NORMALIZATION

Functional Dependencies

Introduction to Data Management. Lecture #7 (Relational DB Design Theory II)

CMPT 354: Database System I. Lecture 9. Design Theory

CSC 261/461 Database Systems Lecture 11

CS322: Database Systems Normalization

Relational-Database Design

Introduction to Database Systems CSE 414. Lecture 20: Design Theory

Problem about anomalies

Data Bases Data Mining Foundations of databases: from functional dependencies to normal forms

Normal Forms 1. ICS 321 Fall Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa

Relational Design Theory II. Detecting Anomalies. Normal Forms. Normalization

Design Theory. Design Theory I. 1. Normal forms & functional dependencies. Today s Lecture. 1. Normal forms & functional dependencies

Lecture 6 Relational Database Design

Relational Database Design

Design Theory for Relational Databases. Spring 2011 Instructor: Hassan Khosravi

Lecture #7 (Relational Design Theory, cont d.)

Transcription:

Functional Dependencies & Normalization Dr. Bassam Hammo

Redundancy and Normalisation Redundant Data Can be determined from other data in the database Leads to various problems INSERT anomalies UPDATE anomalies DELETE anomalies

Redundancy and Normalisation Normalisation Aims to reduce data redundancy Redundancy is expressed in terms of dependencies Normal forms are defined that do not have certain types of dependency

Functional Dependencies Redundancy is often caused by a functional dependency A functional dependency (FD) is a link between two sets of attributes in a relation We can normalise a relation by removing undesirable FDs

Functional Dependencies (FDs) A functional dependency X Y holds over relation schema R if, for every allowable instance r of R: t1 r, t2 r, π X (t1) π X (t2) implies π Y (t1) = π Y (t2) (where t1 and t2 are tuples; X and Y are sets of attributes) The attribute on the left side of the functional dependency is called the determinant, while the reads as determines

Functional Dependencies In other words there exists a functional dependency between X and Y (X Y), if whenever two rows of the relation have the same values for all the attributes in X, then they also have the same values for all the attributes in Y. Example: SID DormName, Fee (CustomerNumber, ItemNumber, Quantity) Price While a primary key is always a determinant, a determinant is not necessarily a primary key

Normalization Normalization eliminates modification anomalies Deletion anomaly: deletion of a row loses information about two or more entities Insertion anomaly: insertion of a fact in one entity cannot be done until a fact about another entity is added Anomalies can be removed by splitting the relation into two or more relations; each with a different, single theme However, breaking up a relation may create referential integrity constraints Normalization works through classes of relations called normal forms

FDs and Normalisation We define a set of 'normal forms' Each normal form has fewer FDs than the last Since FDs represent redundancy, each normal form has less redundancy than the last Not all FDs cause a problem We identify various sorts of FD that do Each normal form removes a type of FD that is a problem We will also need a way to remove FDs

Reasoning About FDs Given some FDs, we can usually infer additional FDs: title studio, star implies title studio and title star title studio and title star implies title studio, star title studio, studio star implies title star But, title, star studio does NOT necessarily imply that title studio or that star studio An FD f is implied by a set of FDs F if f holds whenever all FDs in F hold. F + = closure of F is the set of all FDs that are implied by F. (includes trivial dependencies )

Rules of Inference Armstrong s Axioms (X, Y, Z are sets of attributes): Reflexivity: If X Y, then X Y 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! i.e., using AA you can compute all the FDs in F+ and only these FDs. Some additional rules (that follow from AA): Union: If X Y and X Z, then X YZ Decomposition: If X YZ, then X Y and X Z

Rules of Inference Rules that follow from AA: Union: If X Y and X Z, then X YZ X Y, XX XY (Aug), so X XY X Z, XY YZ (Aug) so X YZ (Trans)

Rules of Inference Rules that follow from AA: Decomposition: If X YZ, then X Y and X Z X YZ, YZ Y (Reflex), so X Y (Trans) Similar for X Z.

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. X + = Set of all attributes A such that X A is in F + X + := X Repeat until no change: if there is an fd U V in F such that U is in X +, then add V to X + Check if Y is in X + Approach can also be used to find the keys of a relation. If all attributes of R are in the closure of X then X is a superkey for R. Q: How to check if X is a candidate key?

Attribute Closure (example) R = {A, B, C, D, E} F = { B CD, D E, B A, E C, AD B } Is B E in F +? B + = B B + = BCD B + = BCDA B + = BCDAE Yes! and B is a key for R too! Is D a key for R? D + = D D + = DE D + = DEC Nope!

Attribute Closure (example) R = {A, B, C, D, E} F = { B CD, D E, B A, E C, AD B } Is AD a key for R? AD + = AD AD + = ABD and B is a key, so Yes! Is AD a candidate key for R? A + = A, D+ = DEC A,D not keys, so Yes! Is ADE a candidate key for R? No! AD is a key, so ADE is a superkey, but not a candidate key

Normal Forms Any table of data is in 1NF if it meets the definition of a relation A relation is in 2NF if all its non-key attributes are dependent on all of the key (no partial dependencies) If a relation has a single attribute key, it is automatically in 2NF A relation is in 3NF if it is in 2NF and has no transitive dependencies A relation is in BCNF if every determinant is a candidate key A relation is in fourth normal form if it is in BCNF and has no multi-value dependencies