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

Similar documents
Relational Database Design

Schema Refinement and Normal Forms

Relational Design: Characteristics of Well-designed DB

Schema Refinement & Normalization Theory

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

SCHEMA NORMALIZATION. CS 564- Fall 2015

Schema Refinement: Other Dependencies and Higher Normal Forms

Schema Refinement. Feb 4, 2010

CS322: Database Systems Normalization

Constraints: Functional Dependencies

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

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

Functional Dependency and Algorithmic Decomposition

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

Schema Refinement and Normal Forms

CSC 261/461 Database Systems Lecture 11

Constraints: Functional Dependencies

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

Schema Refinement and Normal Forms. Chapter 19

CS54100: Database Systems

Database Design and Normalization

Schema Refinement and Normalization

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

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

Schema Refinement and Normal Forms

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

DECOMPOSITION & SCHEMA NORMALIZATION

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

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

CSC 261/461 Database Systems Lecture 12. Spring 2018

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

Database Design and Implementation

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

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

Schema Refinement and Normal Forms

Functional Dependencies & Normalization. Dr. Bassam Hammo

CSC 261/461 Database Systems Lecture 13. Spring 2018

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

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

Schema Refinement and Normal Forms. Why schema refinement?

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

Chapter 7: Relational Database Design

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

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

Chapter 8: Relational Database Design

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

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

Functional Dependencies

Schema Refinement and Normal Forms Chapter 19

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

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

Lossless Joins, Third Normal Form

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

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

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

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

Chapter 3 Design Theory for Relational Databases

Databases Lecture 8. Timothy G. Griffin. Computer Laboratory University of Cambridge, UK. Databases, Lent 2009

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

Relational Design Theory

DESIGN THEORY FOR RELATIONAL DATABASES. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018

Relational Database Design

Functional Dependencies and Normalization

Normaliza)on and Func)onal Dependencies

Functional Dependencies and Normalization

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

BCNF revisited: 40 Years Normal Forms

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 Dependencies

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

FUNCTIONAL DEPENDENCY THEORY II. CS121: Relational Databases Fall 2018 Lecture 20

Chapter 10. Normalization Ext (from E&N and my editing)

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

Information Systems (Informationssysteme)

CSE 132B Database Systems Applications

Chapter 3 Design Theory for Relational Databases

Introduction to Data Management CSE 344

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #15: BCNF, 3NF and Normaliza:on

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

Functional Dependency Theory II. Winter Lecture 21

Functional Dependencies

Database System Concepts, 5th Ed.! Silberschatz, Korth and Sudarshan See for conditions on re-use "

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

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

CSE 544 Principles of Database Management Systems

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

Relational-Database Design

Figure 1.1: Name. Dependent. Name. Depend-emp. Location. Address. Works-for department. Salary employees. Number SSN. Manages. Name ISA.

Databases 2012 Normalization

Practice and Applications of Data Management CMPSCI 345. Lecture 16: Schema Design and Normalization

Kapitel 3: Formal Design

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

Lecture 6 Relational Database Design

Relational Normalization: Contents

HKBU: Tutorial 4

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

Problem about anomalies

Normal Forms Lossless Join.

Chapter 11, Relational Database Design Algorithms and Further Dependencies

Transcription:

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

Armstrong s Axioms with explanation and examples Reflexivity: If X Y, then X Y. (identity function is a function) Augmentation: If X Y, then XZ YZ, for any Z. (parallel application of one function and the identity function is a function) Transitivity: If X Y and Y Z, then X Z. (composition of two functions is a function) Examples: Reflexivity: ssn ssn, ssn,name ssn Augmentation: If ssn name then ssn,color name,color Transitivity: If ssn mgr-id and mgr-id mgr-name, then ssn mgr-name. 2

Using Armstrong s Axioms 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. Decomposition: If X YZ, then X Y and X Z Proof: X YZ given YZ Y Reflexivity (trivial FD) X Y Transitivity (Similarly, X Z.) 3

Using Armstrong s Axioms (cont.) Proposition - Superkeys can be derived from keys: If X Y, then XA Y, for any A Example: If SSN name, then SSN,color name Proof: X Y Given XA YA Augmentation XA Y Decomposition (proved on previous slide) I can construct a superkey from a key. 4

Using Armstrong s Axioms (cont.) Proposition: If X A and X is a superkey (and not a key) for the table, then X A is derivable from a key. Proof: X A X = Y Z where: Y is a key, Z is non-empty, Y and Z disjoint Y A Given Because X is a superkey but not a key Because Y is a key for the table that A is in Therefore X A follows from: Y A (implied by the key) and the result from the previous slide. 5

Formal definition of BCNF (in the textbook) - revisited For a table R, every FD X A that occurs among attributes of R then either: A is an element of X (X A is trivial) A is part of a key (don t worry about key attributes) X is a superkey of R consider the following 2 cases: X is a key for R (good) X is a superkey for R (and not a key). The X A is derivable from a key using augmentation and decomposition. For a table to be in BCNF, every FD is either trivial or derivable from the FDs implied by the key(s). Informally, I often say, BCNF if all FDs are implied by the key(s). 6

Formal definition of 3NF (in the textbook) For a table R, every FD X A that occurs among attributes of R then either: A is an element of X (X A is trivial) A is part of a key (ignore the key attributes) X is a superkey of R Consider the following 2 cases: X is a key for R (good) X is a superkey for R (and not a key). The X A is derivable from a key using augmentation. (Stay tuned.) A table is in 3NF if all the non-key attributes are either trivial or implied by FDs derivable from the FDs implied by the key(s). CS386/586 Winter 2010, Copyright Lois Delcambre 7

Using Armstong s Axioms to show dependency preservation (that SSN dname is not lost) Employee (SSN, name, phone, dept, dept-name) Employee (SSN, name, phone, dept) Department (dept, dname) F = {SSN name, SSN phone, SSN dept, SSN dept-name, dept dname} original set of FDs G = {SSN name, SSN phone, SSN dept, SSN dept-name, dept dname} the set of FDs projected from F But G + includes SSN dept-name because we can derive it: SSN dept Given (it is in G) dept dname Given (it is in G) SSN dname Because of transitivity. 8

Example showing that we must project from F + when considering dependency preservation R(a, b, c) where ab is a key, a b, b a, a c F = {ab c, b a, a b, a c} Suppose we decompose to X(a, b) and Y(b, c) If we project F onto X and Y, we see: a b, b a and that s it. We appear to have lost many FDs. But F + includes this additional FD: b c (because b a and a c) If we project F + onto X and Y we see: a b, b a, and b c in G. G + then includes a b, b a, b c, plus a c (by transitivity), ab c (by augmentation). 9

Same example using realistic attribute names R(ssn, id, name) where (ssn, id) is a key, F = {ssn id, id ssn, ssn name} X(ssn, id) Y(id, name) Projection of F = {ssn id, id ssn} But F + includes id name (because id ssn, and ssn name) Projection of F + includes {ssn id, id ssn, id name} From that projection, we can compute G+ which includes ssn name (because ssn id, id name) 10

Challenge Question Proposition: If AB C (where A and B are disjoint sets of attributes) then A C and B C. Is this true or false? Can you prove/disprove it? 11

Other Normalization Results When a table is in BCNF, it is not possible to have redundancies or update anomalies caused by FDs. There are other dependencies besides FDs. Multi-valued dependency leads to the definition of 4NF Join dependency leads to the definition of 5NF For FDs, MVDs, and JDs, the project operator is used to decompose and the join operator is used to recontruct. There are no redundancies or update anomalies that remain in a table in 5NF that can be solved by projecting/joining. 5NF is sometimes PJNF. 12

Normalization made easy Every attribute in a table must depend on the key (definition of a key), the whole key (2NF no partial dependencies) and nothing but the key (3NF no transitive dependencies). Every non-key attribute in a table must depend on the key (definition of a key) the whole key (2NF no partial dependencies) and nothing but the key (3NF no transitive dependencies). 13