Database Design and Normalization



Similar documents
Schema Refinement and Normalization

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

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

Database Design and Normalization

Lecture Notes on Database Normalization

Normalisation. Why normalise? To improve (simplify) database design in order to. Avoid update problems Avoid redundancy Simplify update operations

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

Relational Database Design

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

Relational Normalization Theory (supplemental material)

Functional Dependencies and Normalization

Database Management Systems. Redundancy and Other Problems. Redundancy

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

Chapter 7: Relational Database Design

Functional Dependencies and Finding a Minimal Cover

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

Design of Relational Database Schemas

Database Design and Normal Forms

CS143 Notes: Normalization Theory

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

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

Introduction to Database Systems. Normalization

Chapter 10. Functional Dependencies and Normalization for Relational Databases

Theory of Relational Database Design and Normalization

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

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

Schema Refinement, Functional Dependencies, Normalization

How To Find Out What A Key Is In A Database Engine

Chapter 8. Database Design II: Relational Normalization Theory

Relational Database Design Theory

Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Overview - detailed. Goal. Faloutsos CMU SCS

Normalization in Database Design

An Algorithmic Approach to Database Normalization

Unit 3.1. Normalisation 1 - V Normalisation 1. Dr Gordon Russell, Napier University

Unique column combinations

Advanced Relational Database Design

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

Functional Dependency and Normalization for Relational Databases

Theory I: Database Foundations

Limitations of DB Design Processes

Chapter 9: Normalization

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

Design Theory for Relational Databases: Functional Dependencies and Normalization

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

Normalization. CIS 331: Introduction to Database Systems

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

Graham Kemp (telephone , room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.

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

RELATIONAL DATABASE DESIGN

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

Normalisation 1. Chapter 4.1 V4.0. Napier University

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

3. Database Design Functional Dependency Introduction Value in design Initial state Aims

Part 6. Normalization

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

CSCI-GA Database Systems Lecture 7: Schema Refinement and 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

Database Constraints and Design

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

Relational Database Design: FD s & BCNF

DATABASE SYSTEMS. Chapter 7 Normalisation

DATABASE NORMALIZATION

Normalization. Reduces the liklihood of anomolies

Online EFFECTIVE AS OF JANUARY 2013

Conceptual Design Using the Entity-Relationship (ER) Model

Database Management System

Visa Smart Debit/Credit Certificate Authority Public Keys

Database Sample Examination

Normalization in OODB Design

Effective Pruning for the Discovery of Conditional Functional Dependencies

Determination of the normalization level of database schemas through equivalence classes of attributes

Introduction to normalization. Introduction to normalization

TYPICAL QUESTIONS & ANSWERS

C# Cname Ccity.. P1# Date1 Qnt1 P2# Date2 P9# Date9 1 Codd London Martin Paris Deen London

Boolean Algebra Part 1

Boolean Algebra (cont d) UNIT 3 BOOLEAN ALGEBRA (CONT D) Guidelines for Multiplying Out and Factoring. Objectives. Iris Hui-Ru Jiang Spring 2010

Normal forms and normalization

Normalization for Relational DBs

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

CH3 Boolean Algebra (cont d)

Unit 3 Boolean Algebra (Continued)

User Manual. for the. Database Normalizer. application. Elmar Jürgens

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

Functional Dependencies

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

LOGICAL DATABASE DESIGN

Geometry Handout 2 ~ Page 1

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

The class slides, your notes, and the sample problem that we worked in class may be helpful for reference.

The University of the State of New York REGENTS HIGH SCHOOL EXAMINATION GEOMETRY. Thursday, January 24, :15 a.m. to 12:15 p.m.

Discovering Conditional Functional Dependencies

Department of Computer Science 2015/16

Algebraic Properties and Proofs

How to bet using different NairaBet Bet Combinations (Combo)

Boyce-Codd Normal Form

Quadrilateral Geometry. Varignon s Theorem I. Proof 10/21/2011 S C. MA 341 Topics in Geometry Lecture 19

The common ratio in (ii) is called the scaled-factor. An example of two similar triangles is shown in Figure Figure 47.1

Normalization. Normalization. Normalization. Data Redundancy

Transcription:

Database Design and Normalization Chapter 10 (Week 11) EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 1

Computing Closure F + Example: List all FDs with: - a single attribute on left - two attributes on left - three attributes on left A B C D a1 b1 c1 d1 a1 b1 c2 d2 a2 b1 c1 d3 a2 b1 c3 d4 EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 2

Computing Closure F + Example: Let F = { A B, B C, C D, D E, E F, F G, G H} How many Fds in F + and how to find them? EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 3

Reasoning About FDs (Contd.) Computing the closure of a set of FDs can be expensive. (Size of closure is exponential in # attrs!) Typically, we just want to check if a given FD X Y is in the closure of a set of FDs F. An efficient check: Compute attribute closure of X (denoted X + ) wrt F: Set of all attributes A such that X A is in F + There is a linear time algorithm to compute this. Check if Y is in X + Does F = {A B, B C, C D E } imply A E? i.e, is A E in the closure F +? Equivalently, is E in A+? EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 4

Computing Closure (see algorithm in section 10.5) Algorithm rule: If X YZ and Z W then X YZW Example: A B, A GC GD F A ABGC Example: A B, A GC, GD FGB E, BC D Compute A+ A ACDFBGE EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 5

Minimal Cover for a Set of FDs Cover G is a set of FDs covered by another set of FDs F of G can be derived from F, that is, F+ G Minimal cover G for a set of FDs F: Closure of F = closure of G. Right hand side of each FD in G is a single attribute. If we modify G by deleting an FD or by deleting attributes from an FD in G, the closure changes. Intuitively, every FD in G is needed, and ``as small as possible in order to get the same closure as F. e.g., A B, ABCD E, EF GH, ACDF EG has the following minimal cover: A B, ACD E, EF G and EF H EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 6

Computing Minimal Cover Step 1 From set F create an equivalent set H of FDs with only single attributes on the R.H.S. Step 2 From H, successively remove individual FDs that are inessential in H. In other words, after removal, the new set remains equivalent to H. Step 3 Now successively replace individual FDs with FDs that have a smaller number of attributes on the LHS, in a manner that does not change H+. (You may need to repeat Step 2) Step 4 From the remaining set of FDs, gather all FDs with equal left-hand sides and use the union rule to create an equivalent FDs where all left-hand sides are unique. (You may not get singleton on RHS) EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 7

Computing Minimal Cover Exmaple: ABD AC, C BE, AD BF, B E Step 1 H = {ABD A, ABD C, C B, C E, AD B,AD F, B E} Step 2 - ABD A is not essential. - How about ABD C? It cannot be derived from other FDs using set closure rule. - How about C B? Can it be implied by other FDs? Compute C+={CE}. Since, C* does not contain B, C B is essential. - C E is inessential - Compute (AD)+=(ADF), so AD B is essential. How about AD F? No FD has F on left hand side. So this is essential. - Also, B E is essential. H = {ABD C, C B, C E, AD B, AD F, B E} EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 8

Computing Minimal Cover Step 3 Can we drop A in ABD C? The new set J={BD C, C B, C E, AD B, AD F, B E} Is J=H? Yes iff (BD)+ under H = BD+ under J. BDE is not equal BDC. So we cannot drop A. Proceed on this line and repeat Step 2. H={AD C, C B, AD F, B E} Step 4 H={AD CF, C B, B E} EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 9

Computing Minimal Cover Example: F={AB C, C A, BC D, ACD B, D G, BE C, CG BD, CE AG } Minimal covers: H={AB C, C A, BC D, CD B, D E, D G, BE C, CG D, CE G } H={AB C, C A, BC D, D E, D G, BE C, CG B, CE G } EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 10

Normal Forms Returning to the issue of schema refinement, the first question to ask is whether any refinement is needed! If a relation is in a certain normal form (BCNF, 3NF etc.), it is known that certain kinds of problems are avoided/minimized. This can be used to help us decide whether decomposing the relation will help. Role of FDs in detecting redundancy: Consider a relation R with 3 attributes, ABC. No FDs hold: There is no redundancy here. Given A B: Several tuples could have the same A value, and if so, they ll all have the same B value! EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 11

Normalization (Chapter 11) Universe of relations(normalized and unnormalized) 1NF relations 2NF relations 3NF relations BCNF relations 4NF relations PJ/NF (5NF) relation EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 12

Moving Towards 3N Form Objective 3NF R is in 3NF iff its non-key attributes (if any) are mutually independent i.e. no FD s among them. Full dependence on the P. Key EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 13

1NF FIRST S# Status City P# Qty S1 20 London P1 300 S1 20 London P2 200 S1 20 London P3 400 S1 20 London P4 200 S1 20 London P5 100 S1 20 London P6 100 S2 10 Paris P1 300 S2 10 Paris P2 400 S3 10 Paris P2 200 S4 20 London P2 200 S4 20 London P4 300 S4 20 London P5 400 Sample tabulation of FIRST EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 14

1NF A relation R is in 1NF iff all underlying simple domains contain atomic values QTY S# P# Status City EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 15

Problems with 1NF Example Insert: We cannot insert a supplier. Why? Delete: Problem? Update: Problem? EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 16

2N Form Convert 1NF 2NF (using Projection) R is in 1NF. Must has a composite P.K. Project into two relations R1 and R2 Def: R is in 2NF if it is 1NF and every non-key attribute is fully dependent on the P.K. EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 17

Procedure 1NF 2NF If R(A,B,C,D) P.Key (A,B) with A D Then generate R2 and R2 (lossless) R1 (A,D) R2 (A,B,C) P.Key = A P.Key = (A,B) F.Key = (A) reference R1 EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 18