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

Similar documents
Relational Design Theory

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

Design Theory for Relational Databases

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

Design Theory for Relational Databases

Chapter 3 Design Theory for Relational Databases

CS54100: Database Systems

Functional Dependencies and Normalization. Instructor: Mohamed Eltabakh

Relational Database Design

CSC 261/461 Database Systems Lecture 11

Design theory for relational databases

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

Introduction to Data Management CSE 344

SCHEMA NORMALIZATION. CS 564- Fall 2015

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

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

Database Design and Implementation

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

Databases 2012 Normalization

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

Functional Dependencies & Normalization. Dr. Bassam Hammo

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

Chapter 3 Design Theory for Relational Databases

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

CSE 344 AUGUST 3 RD NORMALIZATION

CSE 344 MAY 16 TH NORMALIZATION

Schema Refinement and Normal Forms

Schema Refinement and Normal Forms. Why schema refinement?

Lectures 6. Lecture 6: Design Theory

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

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

INF1383 -Bancos de Dados

DECOMPOSITION & SCHEMA NORMALIZATION

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

CSC 261/461 Database Systems Lecture 13. Spring 2018

CS322: Database Systems Normalization

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

CSC 261/461 Database Systems Lecture 12. Spring 2018

Schema Refinement and Normal Forms. Chapter 19

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

CSE 544 Principles of Database Management Systems

Introduction to Management CSE 344

Schema Refinement. Feb 4, 2010

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

Lossless Joins, Third Normal Form

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

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

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

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

Functional Dependency Theory II. Winter Lecture 21

Schema Refinement and Normal Forms

CS 186, Fall 2002, Lecture 6 R&G Chapter 15

Schema Refinement & Normalization Theory

Functional Dependencies

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

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

Problem about anomalies

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

CSE 132B Database Systems Applications

Relational Database Design

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

Constraints: Functional Dependencies

Schema Refinement and Normal Forms Chapter 19

Chapter 7: Relational Database Design

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

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

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

Functional Dependencies and Normalization

Schema Refinement and Normalization

Chapter 8: Relational Database Design

Relational-Database Design

Schema Refinement and Normal Forms

Schema Refinement: Other Dependencies and Higher Normal Forms

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

Information Systems (Informationssysteme)

Constraints: Functional Dependencies

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

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

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

MIS Database Systems Schema Refinement and Normal Forms

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

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

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

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

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

CSE 344 AUGUST 6 TH LOSS AND VIEWS

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

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

MIS Database Systems Schema Refinement and Normal Forms

Database Tutorial 2: Functional Dependencies and Normal Forms

Functional Dependencies. Chapter 3

Desirable properties of decompositions 1. Decomposition of relational schemes. Desirable properties of decompositions 3

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

Relational Design: Characteristics of Well-designed DB

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

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

Functional Dependencies

Transcription:

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 4: DESIGN THEORIES (FUNCTIONAL DEPENDENCIES)

Design theory E/R diagrams are high-level design Formal theory for relational design Evaluate the design for potential problems Modify the relations to avoid them 2

Functional Dependencies (FD) Not exactly like a regular function f(x)=y Generalize the idea of a key: one (or more) attribute(s) identifies the value(s) of one (or more) other attribute(s) Identify the constraints of the system 3

FD Formal Definition X A is an assertion about a relation R that whenever two tuples of R agree on all the attributes of X, then they must also agree on the attribute A. Say X A holds in R. Convention:, X, Y, Z represent sets of attributes; A, B, C, represent single attributes. Convention: no set formers in sets of attributes, just ABC, rather than {A,B,C}. 4

Example Title Year Length Genre studioname starname Forrest Gump 1994 142 Drama Paramount Tom Hanks Titanic 1997 195 Romance 20 th Century Fox Kate Winslet Titanic 1997 195 Romance 20 th Century Fox Leonardo DiCaprio Terminator-2 1991 154 Action Carolco Pictures Arnold Schwarzenegger Reasonable FD s to assert: 1. Title Year Length 2. Title starname Genre 3. Title Year starname length Genre studioname 5

FD s and Keys Keys can be defined using FD s A set of attributes {A 1, A 2,, A n } is a key if: It functionally determines all other attributes of a relation, R No proper subset of {A 1, A 2,, A n } functionally determines all other attributes of R Superkeys can also be defined: A set of attributes {A 1, A 2,, A n } is a superkey if: It functionally determines all other attributes of a relation, R Definitions may vary based on book 6

Example Movies1(Title, Year, Length, Genre, studioname, starname) {Ttile, Year, starname} is a key because together these attributes determine all the other attributes and is minimal. Title Year Length Genre studioname Superkeys: {Ttile, Year, starname, studioname} 7

E/R and Relational Keys Keys in E/R concern entities. Keys in relations concern tuples. Usually, one tuple corresponds to one entity, so the ideas are the same. But --- in poor relational designs, one entity can become several tuples, so E/R keys and Relational keys are different. 8

Rules About FD s (1) Splitting/Combining Rule A 1 A 2 A n B 1 B 2 B m is equivalent to A 1 A 2 A n B 1 A 1 A 2 A n B 2... A 1 A 2 A n B m Example: Title Year Length Genre Is equivalent to Title Year Length, Title Year Genre

Trivial Functional Dependency If B 1 B 2 B m A 1 A 2 A n then A 1 A 2 A n B 1 B 2 Example: B m Title Title Year starname Therefore Title Year starname Title

Rules About FD s (2) Trivial-dependency rule A 1 A 2 A n B 1 B 2 B m is equivalent to A 1 A 2 A n C 1 C 2 C k Where the C s are B - A Example: Title Year Year Length Genre is equivalent to Title Year Length Genre

Rules About FD s (3) Transitivity Rule A 1 A 2 A n B 1 B 2 B m and B 1 B 2 B m C 1 C 2 C k Then A 1 A 2 A n C 1 C 2 C k Example: Movies2(Title, Year, Length, Genre, studioname, studioaddress) Title Year studioname studioname studioaddress Then Title Year studioaddress

Closure Test X Initial set of attributes A closure For a set of attributes Y, closure set {Y} + contains all the attributes that are functionally dependent on Y based on a set of FD s S An easier way to test Y B is to check if B {Y} + Basis: Y + = Y. Induction: Look for an FD whose left side X is a subset of the current Y +. If the FD is X -> A, add A to Y +. Continue until Y + cannot be changed. 13

Y + 14

X Y + 15

X A Y + 16

X A Y + new Y + 17

Example A relation with attributes A,B,C,D,E and F S = {AB C, BC AD, D E and CF B} We want to find X={A,B} + Step 1: Split rights S = {AB C, BC A, BC D, D E and CF B} Step 2: Initialize X={A,B}. First iteration: add C to X because AB C Second iteration: add D to X because BC D Third iteration: add E to X because D E Stop Output: {A,B} + = {A,B,C,D,E}

Anomalies 1. Redundancy 2. Update Anomalies 3. Deletion Anomalies Title Year Length Genre studioname starname Forrest Gump 1994 142 Drama Paramount Tom Hanks Titanic 1997 195 Romance 20 th Century Fox Kate Winslet Titanic 1997 195 Romance 20 th Century Fox Leonardo DiCaprio Terminator-2 1991 154 Action Carolco Pictures Arnold Schwarzenegger Solution: Decompose the relation

Types of Decompositions 1. Boyce-Codd Normal Form 2. Third Normal Form 3. Fourth Normal Form Details: Next Class

Finding All Implied FD s Motivation: normalization, the process where we break a relation schema into two or more schemas. Example: ABCD with FD s AB C, C D, and D A. Decompose into ABC, AD. What FD s hold in ABC? Not only AB C, but also C A! 21

Basic Idea 1. Start with given FD s and find all nontrivial FD s that follow from the given FD s. Nontrivial = left and right sides disjoint. 2. Restrict to those FD s that involve only attributes of the projected schema. 22

Simple, Exponential Algorithm 1. For each subset of attributes X, compute X +. 2. Add X A for all A in X + \ X. 3. However, drop XY A whenever we discover X A. Because XY A follows from X A in any projection. 4. Finally, use only FD s involving projected attributes. 23

A Few Tricks 1. No need to compute the closure of the empty set or of the set of all attributes. 2. If we find X + = all attributes, so is the closure of any superset of X. 24

Example ABC with FD s A B and B C. Project onto AC. A + =ABC ; yields A B, A C. We do not need to compute AB + or AC +. B + =BC ; yields B C. C + =C ; yields nothing. BC + =BC ; yields nothing. 25

Example --- Continued Resulting FD s: A B, A C, and B C. Only FD that involves a subset of {A,C}. 26