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

Similar documents
Chapter 7: Relational Database Design

Functional Dependencies

Chapter 6: Relational Database Design

Lecture 11 - Chapter 8 Relational Database Design Part 1

customer = (customer_id, _ customer_name, customer_street,

Lecture 14 of 42. E-R Diagrams, UML Notes: PS3 Notes, E-R Design. Thursday, 15 Feb 2007

NORMAL FORMS. CS121: Relational Databases Fall 2017 Lecture 18

Normal Forms. Winter Lecture 19

Functional dependency theory

Normalisation theory

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

Databases Tutorial. January 19,2012 Jing Chen Mcmaster University

Combining schemas. Problems: redundancy, hard to update, possible NULLs

Chapter 8: Relational Database Design

Relational Database Design (II)

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

Unit 3 : Relational Database Design

CSIT5300: Advanced Database Systems

Redundancy:Dependencies between attributes within a relation cause redundancy.

UNIT 3 DATABASE DESIGN

CSE 562 Database Systems

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

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

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

Exam I Computer Science 420 Dr. St. John Lehman College City University of New York 12 March 2002

Design Theory for Relational Databases

Functional Dependencies CS 1270

QUESTION BANK. SUBJECT CODE / Name: CS2255 DATABASE MANAGEMENT SYSTEM UNIT III. PART -A (2 Marks)

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

Review: Attribute closure

Lectures 12: Design Theory I. 1. Normal forms & functional dependencies 2/19/2018. Today s Lecture. What you will learn about in this section

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

The Relational Model and Normalization

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

Schema Refinement: Dependencies and Normal Forms

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

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

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

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

Fundamentals of Database Systems

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

Part II: Using FD Theory to do Database Design

FUNCTIONAL DEPENDENCIES CHAPTER , 15.5 (6/E) CHAPTER , 10.5 (5/E)

Schema Refinement: Dependencies and Normal Forms

Normalisation. Normalisation. Normalisation

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

Schema Refinement: Dependencies and Normal Forms

DBMS Chapter Three IS304. Database Normalization-Comp.

CS 338 Functional Dependencies

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

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

Introduction to Database Design, fall 2011 IT University of Copenhagen. Normalization. Rasmus Pagh

CS352 Lecture - Conceptual Relational Database Design

Databases -Normalization I. (GF Royle, N Spadaccini ) Databases - Normalization I 1 / 24

Relational Design: Characteristics of Well-designed DB

This lecture. Databases -Normalization I. Repeating Data. Redundancy. This lecture introduces normal forms, decomposition and normalization.

Informal Design Guidelines for Relational Databases

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

Normalization. CMSC 461 Michael Wilson

Functional Dependencies and Finding a Minimal Cover

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

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

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

CMU SCS CMU SCS CMU SCS CMU SCS whole nothing but

The Relational Data Model

Theory of Normal Forms Decomposition of Relations. Overview

Steps in normalisation. Steps in normalisation 7/15/2014

CSCI 403: Databases 13 - Functional Dependencies and Normalization

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

Final Review. Zaki Malik November 20, 2008

COSC Dr. Ramon Lawrence. Emp Relation

A database can be modeled as: + a collection of entities, + a set of relationships among entities.

DATABASTEKNIK - 1DL116

Functional Dependencies and Single Valued Normalization (Up to BCNF)

CS352 Lecture - Conceptual Relational Database Design

Relational Design 1 / 34

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

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

Chapter 2: Relational Model

Introduction to Databases, Fall 2003 IT University of Copenhagen. Lecture 4: Normalization. September 16, Lecturer: Rasmus Pagh

SCHEMA REFINEMENT AND NORMAL FORMS

Database Design Theory and Normalization. CS 377: Database Systems

BCNF. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong BCNF

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

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

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

Edited by: Nada Alhirabi. Normalization

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

MODULE: 3 FUNCTIONAL DEPENDENCIES

Desirable database characteristics Database design, revisited

Lecture 6a Design Theory and Normalization 2/2

CS 2451 Database Systems: Database and Schema Design

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, normal forms. University of Edinburgh - January 25 th, 2016

In This Lecture. Normalisation to BCNF. Lossless decomposition. Normalisation so Far. Relational algebra reminder: product

Databases The theory of relational database design Lectures for m

Case Study: Lufthansa Cargo Database

Database Systems. Answers

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

Desired properties of decompositions

Database Systems. Basics of the Relational Data Model

Transcription:

Databases Tutorial March,15,2012 Jing Chen Mcmaster University

Outline 1NF Functional Dependencies BCNF 3NF

Larger Schema Suppose we combine borrower and loan to get bor_loan - borrower = (customer_id, loan_number) - loan = (loan_number, amount) - bor_loan = (customer_id, loan_number, amount )

Larger Schema (Cont.) Redundancy! Inconsistency!

Larger Schema (Cont.) Suppose we combine loan and loan_branch to get loan_amt_br - loan = (loan_number, amount) - Loan_branch = (loan_number, branch_name) - Loan_amt_br = (loan_number, amount, branch_name )

Larger Schema (Cont.) Null values!

Smaller Schema Suppose we split up employee into employee1 and employee2 - employee = (id, name, telephone_number, start_date) - employee1 = (id, name) - employee2 = (name, telephone_number, start_date)

Lossy Decomposition

First Normal Form (1NF) Domain is atomic if its elements are considered to be indivisible units A relational schema R is in first normal form if the domains of all attributes of R are atomic Exmaple - Identification numbers like CS101 that can be broken up into parts

Functional Dependencies Let R be a relation schema α R and β R The functional dependency α β holds on R if and only if for any legal relations r(r), whenever any two tuples t 1 and t 2 of r agree on the attributes α, they also agree on the attributes β. That is, t 1 [α] = t 2 [α] t 1 [β ] = t 2 [β ] A functional dependency α β is trivial if β α

Functional Dependencies (Cont.) Example R(A,B,C,D), PK=(A,B) Functional dependency α β t1 A a1 B b1 C c1 D d1 (1) α R and β R (2) t1[α] = t2 [α] t1[β ] = t2 [β ] t2 t3 t4 t5 a1 a2 a2 a3 b2 b2 b3 b3 c1 c2 c2 c2 d2 d2 d3 d4 A C does hold C A does NOT hold A,B A is trivial B A is NOT trivial

Boyce-Codd Normal Form (BCNF) R is in BCNF if for any A B one of the following holds -it is a trivial dependency (B is a subset of A) -A is a superkey for R

BCNF (Cont.) Example Consider a relation Winner (Tournament, Year, Name, Province), you know the following facts: the only candidate key is (Tournament, Year) and except the key, there is only one other functional dependency Name Province. (For instance, the tournaments are held once a year, Province is the birth province of the winner, and from each province only a single representative is allowed.) (1) Give a definition of BCNF Answer: A relation R is in BCNF if for any functional dependency α β, either - α β is trivial or - α is a superkey of R

BCNF (Cont.) Example Consider a relation Winner (Tournament, Year, Name, Province), you know the following facts: the only candidate key is (Tournament, Year) and except the key, there is only one other functional dependency Name Province. (For instance, the tournaments are held once a year, Province is the birth province of the winner, and from each province only a single representative is allowed.) (2) Show relation Winner is not in BCNF Answer: Consider the dependency Name Province, it is not trivial. {Name} is not a superkey. Thus, this dependency violates BCNF.

BCNF (Cont.) Example Consider a relation Winner (Tournament, Year, Name, Province), you know the following facts: the only candidate key is (Tournament, Year) and except the key, there is only one other functional dependency Name Province. (For instance, the tournaments are held once a year, Province is the birth province of the winner, and from each province only a single representative is allowed.) (3) Decompose (losslessly) relation Winner into relations that are in BCNF Answer: Tournament (Tournament, Year, Name), where PK=(Tournament, Year) and Player (Name, Province), where PK=(Name), These tables are in BCNF and it is a lossless decomposition

BCNF (Cont.) Decompose a schema into BCNF Suppose we have a schema R and a nontrivial dependency α β causes a violation of BCNF. We decompose R into: - (α U β ) - ( R - ( β - α ) )

Third Normal Form (3NF) R is in 3NF if for any A B one of the following holds - it is a trivial dependency (B is a subset of A) - A is a superkey for R - every attribute t from B-A is a part of a candidate key

3NF (Cont.) Example Consider a relation SALES (CustomerID, CustomerName, Salesperson, Region) (1) fact: the only candidate key is CustomerID (2) fact: Salesperson Region Answer: the dependency Salesperson Region violates 3NF Decomposition: SALES(CustomerID,CustomerName,Salesperson) PK=CustomerID SALESPERSON(Salesperson, Region) PK=Saleperson these tables are in 3NF and it is a lossless decomposition.

Reference Databases system concepts, fifth edition, Authored by Abraham Silberschatz, Henry F.Korth, S.Sudarshan Slides of Chapter 7: Relational Databases Design,Databases system concepts, fifth edition, Authored by Abraham Silberschatz, Henry F.Korth, S.Sudarshan Databases course website > Help > 3NF exercises, Copyright preserved by Dr. Frantisek (Franya) FRANEK Midterm 2 of 2010, Copyright preserved by Dr. Frantisek (Franya) FRANEK