Chapter 7: Relational Database Design



Similar documents
Boyce-Codd Normal Form

Chapter 7: Relational Database Design

Relational Database Design

Functional Dependencies

Design of Relational Database Schemas

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

Database Design and Normalization

Design Theory for Relational Databases: Functional Dependencies and Normalization

Chapter 6: Integrity Constraints

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

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

Relational Database Design: FD s & BCNF

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

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

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

Schema Refinement, Functional Dependencies, Normalization

Advanced Relational Database Design

Functional Dependencies and Finding a Minimal Cover

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Introduction to Database Systems. Normalization

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

Theory of Relational Database Design and Normalization

Chapter 10. Functional Dependencies and Normalization for Relational Databases

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

MCQs~Databases~Relational Model and Normalization

Relational Database Design Theory

B2.2-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

Database Management Systems. Redundancy and Other Problems. Redundancy

Schema Refinement and Normalization

Database Design and Normal Forms

Chapter 2: Entity-Relationship Model

CS143 Notes: Normalization Theory

Database Management System

Lecture Notes on Database Normalization

Introduction to SQL ( )

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

Functional Dependencies and Normalization

Theory of Relational Database Design and Normalization

Relational Normalization Theory (supplemental material)

Introduction Decomposition Simple Synthesis Bernstein Synthesis and Beyond. 6. Normalization. Stéphane Bressan. January 28, 2015

DATABASE NORMALIZATION

Database Systems Concepts, Languages and Architectures

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

Normalization. CIS 331: Introduction to Database Systems

Chapter 10 Functional Dependencies and Normalization for Relational Databases

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

Functional Dependency and Normalization for Relational Databases

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

Normalization in OODB Design

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

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

Chapter 8. Database Design II: Relational Normalization Theory

Lecture 2 Normalization

Comp 3311 Database Management Systems. 2. Relational Model Exercises

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

Simple SQL Queries (3)

Normalization of Database

Database Constraints and Design

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

Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES

DATABASE SYSTEMS. Chapter 7 Normalisation

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

BCA. Database Management System

Normal forms and normalization

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

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

Normalization in Database Design

6.2 Permutations continued

SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints

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

A Web-Based Environment for Learning Normalization of Relational Database Schemata

Chapter 1: Introduction

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

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

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

Limitations of DB Design Processes

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Lesson 8: Introduction to Databases E-R Data Modeling

Advance DBMS. Structured Query Language (SQL)

Fundamentals of Database System

More on SQL. Juliana Freire. Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan

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

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7

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

City University of Hong Kong. Information on a Course offered by Department of Computer Science with effect from Semester A in 2014 / 2015

Topic 5.1: Database Tables and Normalization

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

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

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

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

RELATIONAL DATABASE DESIGN

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen

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

1. A table design is shown which violates 1NF. Give a design which will store the same information but which is in 1NF.

IT2304: Database Systems 1 (DBS 1)

Normalization. Normalization. Normalization. Data Redundancy

Introduction to database management systems

Transcription:

Chapter 7: Relational Database Design Pitfalls in Relational Database Design Decomposition Normalization Using Functional Dependencies Normalization Using Multivalued Dependencies Normalization Using Join Dependencies Domain-Key Normal Form Alternative Approaches to Database Design Database Systems Concepts 7.1 Silberschatz, Korth and Sudarshan c 1997

Pitfalls in Relational Database Design Relational database design requires that we find a good collection of relation schemas. A bad design may lead to Repetition of information. Inability to represent certain information. Design Goals: Avoid redundant data Ensure that relationships among attributes are represented Facilitate the checking of updates for violation of database integrity constraints Database Systems Concepts 7.2 Silberschatz, Korth and Sudarshan c 1997

Example Consider the relation schema: Lending-schema =(branch-name, branch-city, assets, customer-name, loan-number, amount) Redundancy: Data for branch-name, branch-city, assets are repeated for each loan that a branch makes Wastes space and complicates updating Null values Cannot store information about a branch if no loans exist Can use null values, but they are difficult to handle Database Systems Concepts 7.3 Silberschatz, Korth and Sudarshan c 1997

Decomposition Decompose the relation schema Lending-schema into: Branch-customer-schema =(branch-name, branch-city, assets, customer-name) Customer-loan-schema =(customer-name, loan-number, amount) All attributes of an original schema (R) must appear in the decomposition (R 1,R 2 ): R = R 1 R 2 Lossless-join decomposition. For all possible relations r on schema R r = Π R1 1 (r) Π R2 (r) Database Systems Concepts 7.4 Silberschatz, Korth and Sudarshan c 1997

Example of a Non Lossless-Join Decomposition Decomposition of R = (A, B) R 1 = (A) R 2 = (B) A B A B α 1 α 1 α 2 β 2 β 1 r Π A (r) Π B (r) Π A (r) 1 Π B (r) A B α 1 α 2 β 1 β 2 Database Systems Concepts 7.5 Silberschatz, Korth and Sudarshan c 1997

Goal Devise a Theory for the Following: Decide whether a particular relation R is in good form. In the case that a relation R is not in good form, decompose it into a set of relations {R 1,R 2,..., R n } such that each relation is in good form the decomposition is a lossless-join decomposition Our theory is based on: functional dependencies multivalued dependencies Database Systems Concepts 7.6 Silberschatz, Korth and Sudarshan c 1997

Normalization Using Functional Dependencies When we decompose a relation schema R with a set of functional dependencies F into R 1 and R 2 we want: Lossless-join decomposition: At least one of the following dependencies is in F+: R 1 R 2 R 1 R 1 R 2 R 2 No redundancy: The relations R 1 and R 2 preferably should be in either Boyce-Codd Normal Form or Third Normal Form. Dependency preservation: Let F i be the set of dependencies in F + that include only attributes in R i. Test to see if: (F 1 F 2 ) + = F + Otherwise, checking updates for violation of functional dependencies is expensive. Database Systems Concepts 7.7 Silberschatz, Korth and Sudarshan c 1997

Example R = (A, B, C) F = {A B, B C} R 1 = (A, B), R 2 = (B, C) Lossless-join decomposition: Dependency preserving R 1 = (A, B), R 2 = (A, C) Lossless-join decomposition: R 1 R 2 = {B} and B BC R 1 R 2 = {A} and A AB Not dependency preserving (cannot check B C without computing R 1 1 R 2 ) Database Systems Concepts 7.8 Silberschatz, Korth and Sudarshan c 1997

Boyce-Codd Normal Form A relation schema R is in BCNF with respect to a set F of functional dependencies if for all functional dependencies in F + of the form α β, where α R and β R, at least one of the following holds: α β is trivial (i.e., β α) α is a superkey for R Database Systems Concepts 7.9 Silberschatz, Korth and Sudarshan c 1997

$ Example R = (A, B, C) F = {A B B C} Key = {A} R is not in BCNF Decomposition R 1 = (A, B), R 2 = (B, C) R 1 and R 2 in BCNF Lossless-join decomposition Dependency preserving Database Systems Concepts 7.10 Silberschatz, Korth and Sudarshan c 1997

BCNF Decomposition Algorithm result := {R}; done := false; compute F + ; while (not done) do if (there is a schema R i in result that is not in BCNF) then begin let α β be a nontrivial functional dependency that holds on R i such that α R i is not in F +, and α β = ; result := (result R i ) (R i β) (α, β); end else done := true; Note: each R i is in BCNF, and decomposition is lossless-join. Database Systems Concepts 7.11 Silberschatz, Korth and Sudarshan c 1997

Example of BCNF Decomposition R =(branch-name, branch-city, assets, customer-name, loan-number, amount) F = {branch-name assets branch-city loan-number amount branch-name} Key = {loan-number, customer-name} Decomposition R 1 =(branch-name, branch-city, assets) R 2 =(branch-name, customer-name, loan-number, amount) R 3 =(branch-name, loan-number, amount) R 4 =(customer-name, loan-number) Final decomposition R 1, R 3, R 4 Database Systems Concepts 7.12 Silberschatz, Korth and Sudarshan c 1997

BCNF and Dependency Preservation It is not always possible to get a BCNF decomposition that is dependency preserving R = (J, K, L) F = {JK L L K } Two candidate keys = JK and JL R is not in BCNF Any decomposition of R will fail to preserve JK L Database Systems Concepts 7.13 Silberschatz, Korth and Sudarshan c 1997