Boyce-Codd Normal Form



Similar documents
Chapter 7: Relational Database Design

Comp 3311 Database Management Systems. 2. Relational Model Exercises

Chapter 7: Relational Database Design

Database Design and Normalization

Functional Dependencies

Chapter 2: Entity-Relationship Model

Lesson 8: Introduction to Databases E-R Data Modeling

We know how to query a database using SQL. A set of tables and their schemas are given Data are properly loaded

Chapter 2: Entity-Relationship Model. Entity Sets. " Example: specific person, company, event, plant

Chapter 2: Entity-Relationship Model. E-R R Diagrams

normalisation Goals: Suppose we have a db scheme: is it good? define precise notions of the qualities of a relational database scheme

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 5: Normalization II; Database design case studies. September 26, 2005

Relational Database Design Theory

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

Introduction to SQL ( )

Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31

B2.2-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1

CS143 Notes: Normalization Theory

Design Theory for Relational Databases: Functional Dependencies and Normalization

Database Management System

Simple SQL Queries (3)

Design of Relational Database Schemas

Relational Database Design

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

Chapter 6: Integrity Constraints

Foundations of Information Management

You can use command show database; to check if bank has been created.

Database Management Systems. Redundancy and Other Problems. Redundancy

Relational Database Design: FD s & BCNF

Database Design and Normal Forms

Comp 5311 Database Management Systems. 3. Structured Query Language 1

Objectives of Database Design Functional Dependencies 1st Normal Form Decomposition Boyce-Codd Normal Form 3rd Normal Form Multivalue Dependencies

CSCI-GA Database Systems Lecture 7: Schema Refinement and Normalization

Converting E-R Diagrams to Relational Model. Winter Lecture 17

RELATIONAL DATABASE DESIGN

Advanced Relational Database Design

Schema Refinement and Normalization

Theory of Relational Database Design and Normalization

Normalization. CIS 331: Introduction to Database Systems

Foundations of Information Management

A. TRUE-FALSE: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ:

SQL is capable in manipulating relational data SQL is not good for many other tasks

Relational Normalization: Contents. Relational Database Design: Rationale. Relational Database Design. Motivation

Lecture Notes on Database Normalization

Functional Dependencies and Finding a Minimal Cover

Functional Dependency and Normalization for Relational Databases

Chapter 10. Functional Dependencies and Normalization for Relational Databases

ER modelling, Weak Entities, Class Hierarchies, Aggregation

Schema Refinement, Functional Dependencies, Normalization

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Introduction to database management systems

DATABASE SYSTEMS. Chapter 7 Normalisation

Normalization of database model. Pazmany Peter Catholic University 2005 Zoltan Fodroczi

Chapter 1: Introduction. Database Management System (DBMS)

Why Is This Important? Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) Example (Contd.)

Introduction to Database Systems. Normalization

Week 11: Normal Forms. Logical Database Design. Normal Forms and Normalization. Examples of Redundancy

Chapter 8. Database Design II: Relational Normalization Theory

Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example

OVERVIEW 1.1 DATABASE MANAGEMENT SYSTEM (DBMS) DEFINITION:-

Chapter 10. Functional Dependencies and Normalization for Relational Databases. Copyright 2007 Ramez Elmasri and Shamkant B.

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

Chapter 10 Functional Dependencies and Normalization for Relational Databases

Database Fundamentals

Introduction to Databases

Basic Concepts. Chapter A: Network Model. Cont.) Data-Structure Diagrams (Cont( Data-Structure Diagrams. General Relationships. The DBTG CODASYL Model

Introduction to Database Systems. Chapter 4 Normal Forms in the Relational Model. Chapter 4 Normal Forms

Lecture 2 Normalization

Advance DBMS. Structured Query Language (SQL)

Database Normalization. Mohua Sarkar, Ph.D Software Engineer California Pacific Medical Center

Normalization in OODB Design

Normalization in Database Design

Fundamentals of Database System

MCQs~Databases~Relational Model and Normalization

Chapter 1: Introduction

Functional Dependencies and Normalization

Theory of Relational Database Design and Normalization

Database Systems Concepts, Languages and Architectures

Relational Normalization Theory (supplemental material)

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization

Normalization. Functional Dependence. Normalization. Normalization. GIS Applications. Spring 2011

DATABASE DESIGN: NORMALIZATION NOTE & EXERCISES (Up to 3NF)

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES

Chapter 6. Database Tables & Normalization. The Need for Normalization. Database Tables & Normalization

Tutorial on Relational Database Design

Limitations of DB Design Processes

Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3)

DATABASE NORMALIZATION

DATABASE MANAGEMENT SYSTEMS. Question Bank:

The E-R èentity-relationshipè data model views the real world as a set of basic objects èentitiesè and

Database Design and Normalization

Quiz 3: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354

Normalization for Relational DBs

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

BCA. Database Management System

Module 5: Normalization of database tables

Theory behind Normalization & DB Design. Satisfiability: Does an FD hold? Lecture 12

Transcription:

4NF

Boyce-Codd Normal Form A relation schema R is in BCNF if for all functional dependencies in F + of the form α β at least one of the following holds α β is trivial (i.e., β α) α is a superkey for R bor_loan = (customer_id, loan_number, amount) is not in BCNF loan_number amount holds on bor_loan but loan_number is not a superkey CMPT 354: Database I -- 4NF 2

Redundancy May Still Exist in BCNF Database classes(course, teacher, book) (c,t,b) classes means that t is qualified to teach c, and b is a required textbook for c course teacher book Hank Hank Sudarshan Sudarshan Jim Jim DB Concepts Ullman DB Concepts Ullman DB Concepts Ullman OS Concepts Shaw OS Concepts Shaw CMPT 354: Database I -- 4NF 3

Insertion Anomalies Relation classes(course, teacher, book) is in BCNF Insertion anomalies If Sara is a new teacher that can teach, two tuples need to be inserted (, Sara, DB Concepts) (, Sara, Ullman) CMPT 354: Database I -- 4NF 4

Decomposition to BCNF course teacher book Hank Hank Sudarshan Sudarshan Jim Jim DB Concepts Ullman DB Concepts Ullman DB Concepts Ullman OS Concepts Shaw OS Concepts Shaw course teaches teacher Hank Sudarshan Jim course text book DB Concepts Ullman OS Concepts Shaw CMPT 354: Database I -- 4NF 5

Multivalued Dependency Let R be a relation schema and let α R and β R The multivalued dependency α β holds on R if in any legal relation r(r), for all pairs for tuples t 1 and t 2 in r such that t 1 [α] = t 2 [α], there exist tuples t 3 and t 4 in r such that: t 1 [α] = t 2 [α] = t 3 [α] = t 4 [α] t 3 [β] = t 1 [β] t 3 [R β] = t 2 [R β] t 4 [β] = t 2 [β] t 4 [R β] = t 1 [R β] CMPT 354: Database I -- 4NF 6

Example In relation classes(course, teacher, book), course teacher course book Given a particular course, it has associated with a set of teachers and a set of values of books, and these two sets are in some sense independent of each other If Y Z then Y Z For relation r not satisfying a given multivalued dependency, relations r can be constructed to satisfy the MVD by adding tuples to r How? CMPT 354: Database I -- 4NF 7

Fourth Normal Form (4NF) A relation schema R is in 4NF with respect to a set D of functional and multivalued dependencies if for all multivalued dependencies in D + of the form α β, where α R and β R, at least one of the following hold α β is trivial (i.e., β αor α β= R) α is a superkey for schema R If a relation is in 4NF, it is in BCNF CMPT 354: Database I -- 4NF 8

Restriction of MV Dependencies D is a set of functional and multivalued dependencies The restriction of D to R i is the set D i consisting of All functional dependencies in D + that include only attributes of R i All multivalued dependencies of the form α (β R i ) where α R i and α β is in D + CMPT 354: Database I -- 4NF 9

4NF Decomposition Algorithm result: = {R}; done := false; compute D + ; Let D i denote the restriction of D + to R i while (not done) if (there is a schema R i in result that is not in 4NF) then begin let α β be a nontrivial multivalued dependency that holds on R i such that α R i is not in D i, and α β=φ; result := (result - R i ) (R i - β) (α, β); end else done:= true; Each R i is in 4NF, and decomposition is lossless-join CMPT 354: Database I -- 4NF 10

Example R =(A, B, C, G, H, I), F ={ A B, B HI, CG H } R is not in 4NF A B and A is not a superkey for R Decomposition a) R 1 = (A, B) (R 1 is in 4NF) b) R 2 = (A, C, G, H, I) (R 2 is not in 4NF) c) R 3 = (C, G, H) (R 3 is in 4NF) d) R 4 = (A, C, G, I) (R 4 is not in 4NF) Since A B and B HI, A HI, A I e) R 5 = (A, I) (R 5 is in 4NF) f)r 6 = (A, C, G) (R 6 is in 4NF) Result: (A, B), (C, G, H), (A, I), (A, C, G) CMPT 354: Database I -- 4NF 11

How to Come up with a Design? R could have been generated when converting E-R diagram to a set of tables R could have been a single relation containing all attributes that are of interest universal relation Normalization breaks R into smaller relations R could have been the result of some ad hoc design of relations, which we then test / convert to normal form CMPT 354: Database I -- 4NF 12

ER Model and Normalization When an E-R diagram is carefully designed, identifying all entities correctly, the tables generated from the E-R diagram should not need further normalization In a real (imperfect) design, there can be FDs from non-key attributes of an entity to other attributes of the entity Employee entity with attributes department-number and department-address, and an FD department-number department-address Good design would have made department an entity FDs from non-key attributes of a relationship set are possible, but rare most relationships are binary CMPT 354: Database I -- 4NF 13

The Universal Relation Approach Dangling tuples: tuples that disappear in a join Let r 1 (R 1 ),., r n (R n ) be a set of relations A tuple r of the relation r i is a dangling tuple if r is not in the relation: Ri (r 1 r n ) The relation r 1 r n is called a universal relation it involves all the attributes in the universe defined by R 1 R 2 R n CMPT 354: Database I -- 4NF 14

Denormalization for Performance May use non-normalized schema for performance Displaying customer-name along with account-number and balance requires join of account with depositor Alternative 1: Use a denormalized relation containing attributes of account as well as depositor with all above attributes Faster lookup Extra space and extra execution time for updates Extra coding work for programmer and possibility of error in extra code Alternative 2: use a materialized view defined as account depositor Benefits and drawbacks same as above, except no extra coding work for programmer and avoiding possible errors CMPT 354: Database I -- 4NF 15

Other Design Issues Some aspects of design are not caught by normalization Instead of earnings (company_id, year, amount ), use company_year(company_id, earnings_2000, earnings_2001, earnings_2002) In BCNF, but make querying across years difficult and needs new table each year Require new attribute each year An example of a crosstab, where values for one attribute become column names Used in spreadsheets, and in data analysis tools CMPT 354: Database I -- 4NF 16

Modeling Temporal Data Temporal data have an association time interval during which the data are valid A snapshot is the value of the data at a particular point in time Adding a temporal component results in functional dependencies like customer_id customer_street customer_city not to hold, because the address varies over time A temporal functional dependency holds on schema R if the corresponding functional dependency holds on all snapshots for all legal instances r (R ) CMPT 354: Database I -- 4NF 17

Summary and To-Do List Multivalued dependencies and 4NF ER model and normalization Normalization and denormalization Why a relation in 4NF is also in BCNF? CMPT 354: Database I -- 4NF 18

The Banking Schema branch = (branch_name, branch_city, assets) customer = (customer_id, customer_name, customer_street, customer_city) loan = (loan_number, amount) account = (account_number, balance) employee = (employee_id. employee_name, telephone_number, start_date) dependent_name = (employee_id, dname) account_branch = (account_number, branch_name) loan_branch = (loan_number, branch_name) borrower = (customer_id, loan_number) depositor = (customer_id, account_number) cust_banker = (customer_id, employee_id, type) works_for = (worker_employee_id, manager_employee_id) payment = (loan_number, payment_number, payment_date, payment_amount) savings_account = (account_number, interest_rate) checking_account = (account_number, overdraft_amount) CMPT 354: Database I -- 4NF 19