Chapter 16. Relational Database Design Algorithms. Database Design Approaches. Top-Down Design

Similar documents
More Normalization Algorithms. CS157A Chris Pollett Nov. 28, 2005.

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

Functional Dependencies & Normalization for Relational DBs. Truong Tuan Anh CSE-HCMUT

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.)

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design

Informal Design Guidelines for Relational Databases

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2

MODULE: 3 FUNCTIONAL DEPENDENCIES

Part II: Using FD Theory to do Database Design

CSIT5300: Advanced Database Systems

Functional Dependencies and Normalization for Relational Databases Design & Analysis of Database Systems

Schema Refinement: Dependencies and Normal Forms

Theory of Normal Forms Decomposition of Relations. Overview

Chapter 10. Chapter Outline. Chapter Outline. Functional Dependencies and Normalization for Relational Databases

Schema Refinement: Dependencies and Normal Forms

Homework 6: FDs, NFs and XML (due April 15 th, 2015, 4:00pm, hard-copy in-class please)

Schema Refinement: Dependencies and Normal Forms

UNIT 3 DATABASE DESIGN

SCHEMA REFINEMENT AND NORMAL FORMS

Schema Normalization. 30 th August Submitted By: Saurabh Singla Rahul Bhatnagar

Functional Dependencies and. Databases. 1 Informal Design Guidelines for Relational Databases. 4 General Normal Form Definitions (For Multiple Keys)

Chapter 14. Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies

Relational Database design. Slides By: Shree Jaswal

Desired properties of decompositions

MIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: Time: 60 min Marks: 38

Database Design Theory and Normalization. CS 377: Database Systems

Functional Dependencies and Finding a Minimal Cover

Relational Design: Characteristics of Well-designed DB

CSE 562 Database Systems

Fundamentals of Database Systems

Chapter 14 Outline. Normalization for Relational Databases: Outline. Chapter 14: Basics of Functional Dependencies and

The strategy for achieving a good design is to decompose a badly designed relation appropriately.

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization

Homework 6. Question Points Score Query Optimization 20 Functional Dependencies 20 Decompositions 30 Normal Forms 30 Total: 100

CS411 Database Systems. 05: Relational Schema Design Ch , except and

COMP7640 Assignment 2

Functional Dependencies CS 1270

DATABASE DESIGN I - 1DL300

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization

Database Management

Guideline 1: Semantic of the relation attributes Do not mix attributes from distinct real world. example

Dr. Anis Koubaa. Advanced Databases SE487. Prince Sultan University

Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please)

Normalisation. Normalisation. Normalisation

Chapter 8: Relational Database Design

Relational Design Theory. Relational Design Theory. Example. Example. A badly designed schema can result in several anomalies.

Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601

Homework 3: Relational Database Design Theory (100 points)

Database Management System

Acknowledgement: The slides were kindly lent by Doc. RNDr. Tomas Skopal, Ph.D., Department of Software Engineering, Charles University in Prague

Databases Tutorial. March,15,2012 Jing Chen Mcmaster University

Lecture 11 - Chapter 8 Relational Database Design Part 1

Relational Database Design (II)

CS 338 Functional Dependencies

Unit 3 : Relational Database Design

V. Database Design CS448/ How to obtain a good relational database schema

Bachelor in Information Technology (BIT) O Term-End Examination

Schema Refinement & Normalization Theory 2. Week 15

Relational design algorithms

CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam

CMU SCS CMU SCS CMU SCS CMU SCS whole nothing but

COSC Dr. Ramon Lawrence. Emp Relation

Exercise 9: Normal Forms

DATABASE MANAGEMENT SYSTEM SHORT QUESTIONS. QUESTION 1: What is database?

Database Management Systems Paper Solution

DATABASE DESIGN I - 1DL300

Normalization 03. CSE3421 notes

Chapter 7: Relational Database Design

5 Normalization:Quality of relational designs

CS352 Lecture - Conceptual Relational Database Design

Review: Attribute closure

DATABASE DESIGN I - 1DL300

Handout 3: Functional Dependencies and Normalization

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

In Chapters 3 through 6, we presented various aspects

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Overview - detailed. Goal. Faloutsos & Pavlo CMU SCS /615

customer = (customer_id, _ customer_name, customer_street,

Functional Dependencies and Normalization

CS352 Lecture - Conceptual Relational Database Design

Normalization. Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms

CS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010

UNIT 8. Database Design Explain multivalued dependency and fourth normal form 4NF with examples.

CS/B.Tech/CSE/New/SEM-6/CS-601/2013 DATABASE MANAGEMENENT SYSTEM. Time Allotted : 3 Hours Full Marks : 70

More Relational Algebra

UNIT -III. Two Marks. The main goal of normalization is to reduce redundant data. Normalization is based on functional dependencies.

Examination examples

Home Page. Title Page. Page 1 of 14. Go Back. Full Screen. Close. Quit

CSCI 403: Databases 13 - Functional Dependencies and Normalization

Lecture #8 (Still More Relational Theory...!)

EECS-3421a: Test #2 Queries

Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010

Lecture 6a Design Theory and Normalization 2/2

Administrivia. Physical Database Design. Review: Optimization Strategies. Review: Query Optimization. Review: Database Design

Relational Design 1 / 34

Draw A Relational Schema And Diagram The Functional Dependencies In The Relation >>>CLICK HERE<<<

Database Systems. Basics of the Relational Data Model

Database design III. Quiz time! Using FDs to detect anomalies. Decomposition. Decomposition. Boyce-Codd Normal Form 11/4/16

Functional dependency theory

Database Constraints and Design

Transcription:

Chapter 16 Relational Database Design Algorithms Database Design Approaches Top-Down design (Starting with conceptual design) Bottom-Up Design (relational synthesis) 2 Top-Down Design Design conceptual schema in a highlevel data model Map the conceptual schema into a set of relations Normalize the relations 3

4 Relational Synthesis Assumes that all possible functional dependencies are known. First construct a minimal set of FDs Then apply algorithms that construct a target set of 3NF or BCNF relations. Additional criteria may be needed to ensure that the set of relations in a relational database are satisfactory Designing a Set of Relations Goals: Lossless join property (a must) Dependency preservation property occasionally must be sacrificed to achieve 3NF or BCNF Additional normal forms 4NF (based on multi-valued dependencies) 5NF (based on join dependencies) 5 General Approach Construct a Universal relation containing ALL the attributes of the database Iteratively decompose the above relation into smaller relations based on the functional dependencies 6

7 Relation Decomposition and Insufficiency of Normal Forms: Universal Relation Schema: a relation schema R={A 1, A 2,, A n } that includes all the attributes of the database. Universal relation assumption: every attribute name is unique. Decomposition: The process of decomposing the universal relation schema R into a set of relation schemas D = {R 1,R 2,, R m } that will become the relational database schema by using the functional dependencies. Attribute preservation condition: Each attribute in R will appear in at least one relation schema R i in the decomposition so that no attributes are lost. Another goal of decomposition is to have each individual relation R i in the decomposition D be in BCNF or 3NF. Additional properties of decomposition are needed to prevent the generation of spurious tuples 8 Dependency Preservation Property of a Decomposition : Dependencies X Y in the universal relation R should either appear directly in some relation R i or can be inferred from the dependencies in R i. It is not necessary that all dependencies from the relation R appear in some relation R i. It is sufficient that the union of the dependencies on all the relations R i be equivalent to the dependencies on R. 9

10 Dependency Preservation Property: a decomposition D = {R 1, R 2,..., R m } of R is dependency-preserving with respect to F if the union of the projections of F on each R i in D is equivalent to F; that is, (( R1 (F)) υ... υ ( Rm (F))) + = F + Claim 1: It is always possible to find a dependencypreserving decomposition D with respect to F such that each relation R i in D is in 3NF. Lossless (Non-additive) Join Property of a Decomposition: A decomposition is lossless if the result of joining (natural join) all the decomposed relations together contains all the tuples from the original relation and does not contain any other tuples. 11 Definition: Lossless join property: a decomposition D = {R 1, R 2,..., R m } of R has the lossless (nonadditive) join property with respect to the set of dependencies F on R if, for every relation state r of R that satisfies F, the following holds, where * is the natural join of all the relations in D: * ( R1 (r),..., Rm (r)) = r Note: The word loss in lossless refers to loss of information, not to loss of tuples. In fact, for loss of information a better term is addition of spurious information 12

13 Successive Lossless Join Decomposition: Claim 2 (Preservation of non-additivity in successive decompositions): If a decomposition D = {R 1, R 2,..., R m } of R has the lossless (nonadditive) join property with respect to a set of functional dependencies F on R, and if a decomposition D i = {Q 1, Q 2,..., Q k } of R i has the lossless (non-additive) join property with respect to the projection of F on R i, then the decomposition D 2 = {R 1, R 2,..., R i-1, Q 1, Q 2,..., Q k, R i+1,..., R m } of R has the non-additive join property with respect to F. Relational Synthesis into 3NF with Dependency Preservation (Relational Synthesis Algorithm) Input: A universal relation R and a set of functional dependencies F on the attributes of R. 1. Find a minimal cover G for F ; 2. For each left-hand-side X of a functional dependency that appears in G, create a relation schema in D with attributes {X υ {A 1 } υ {A 2 }... υ {A k }}, where X A 1, X A 2,..., X A k are the only dependencies in G with X as left-hand-side (X is the key of this relation) ; 3. Place any remaining attributes (that have not been placed in any relation) in a single relation schema to ensure the attribute preservation property. Claim 3: Every relation schema created by the Relational Synthesis Algorithm is in 3NF. 14 Relational Synthesis into 3NF with Dependency Preservation and Lossless (Non-Additive) Join Property Input: A universal relation R and a set of functional dependencies F on the attributes of R. 1. Find a minimal cover G for F. 2. For each left-hand-side X of a functional dependency that appears in G, create a relation schema in D with attributes {X υ {A 1 } υ {A 2 }... υ {A k }}, where X A 1, X A 2,..., X >A k are the only dependencies in G with X as left-hand-side (X is the key of this relation). 3. If none of the relation schemas in D contains a key of R, then create one more relation schema in D that contains attributes that form a key of R 15

16 Finding a Key K for R Given a set F of Functional Dependencies Input: A universal relation R and a set of functional dependencies F on the attributes of R. 1. Set K := R. 2. For each attribute A in K { compute (K - A) + with respect to F; If (K - A) + contains all the attributes in R, then set K := K - {A}; } Relational Decomposition into BCNF with Lossless (non-additive) join property Input: A universal relation R and a set of functional dependencies F on the attributes of R. 1. Set D := {R}; 2. While there is a relation schema Q in D that is not in BCNF do { choose a relation schema Q in D that is not in BCNF; find a functional dependency X Y in Q that violates BCNF; replace Q in D by two relation schemas (Q - Y) and (X υ Y); }; 17 Example 18

19 Example (cont.) Example (cont.) 20 Issues with null-value joins. (a) Some EMPLOYEE tuples have null for the join attribute DNUM. 21

22 Issues with null-value joins. (b) Result of applying NATURAL JOIN to the EMPLOYEE and DEPARTMENT relations. (c) Result of applying LEFT OUTER JOIN to EMPLOYEE and DEPARTMENT. The dangling tuple problem. (a) The relation EMPLOYEE_1 (includes all attributes of EMPLOYEE from frigure 11.2a except DNUM). 23 The dangling tuple problem. (b) The relation EMPLOYEE_2 (includes DNUM attribute with null values). (c) The relation EMPLOYEE_3 (includes DNUM attribute but does not include tuples for which DNUM has null values). 24

25 Problems with Normalization Algorithms The database designer must first specify all the relevant functional dependencies among the database attributes. These algorithms are not deterministic in general. It is not always possible to find a decomposition into relational schemas that preserves dependencies and allows each relation schema in the decomposition to be in BCNF. Exercise Apply the key finding algorithm to the following relation to determine a key. Apply the decomposition and synthesis algorithms to determine the equivalent BCNF and 3NF decompositions: 26