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



Similar documents
Relational Database Design

Functional Dependencies and Normalization

Database Design and Normalization

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

Schema Refinement and Normalization

Lecture Notes on Database Normalization

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Design of Relational Database Schemas

Schema Refinement, Functional Dependencies, Normalization

Database Design and Normal Forms

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

Functional Dependencies and Finding a Minimal Cover

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

Relational Database Design Theory

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

Database Management Systems. Redundancy and Other Problems. Redundancy

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

CS143 Notes: Normalization Theory

Chapter 10. Functional Dependencies and Normalization for Relational Databases

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

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

Relational Database Design: FD s & BCNF

Database Design and Normalization

Introduction to Database Systems. Normalization

Chapter 7: Relational Database Design

Theory of Relational Database Design and Normalization

Relational Normalization Theory (supplemental material)

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

Database Constraints and Design

Advanced Relational Database Design

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

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

Design Theory for Relational Databases: Functional Dependencies and Normalization

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

Chapter 10 Functional Dependencies and Normalization for Relational Databases

Chapter 8. Database Design II: Relational Normalization Theory

Theory of Relational Database Design and Normalization

Limitations of DB Design Processes

Functional Dependencies

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

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

Normalization in Database Design

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

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

An Algorithmic Approach to Database Normalization

Database Management System

Unique column combinations

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

RELATIONAL DATABASE DESIGN

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

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

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

Functional Dependency and Normalization for Relational Databases

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

Normalization for Relational DBs

Chapter 7: Relational Database Design

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

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

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

Database Sample Examination

Part I: Entity Relationship Diagrams and SQL (40/100 Pt.)

DATABASE NORMALIZATION

Database Systems Concepts, Languages and Architectures

Normalisation and Data Storage Devices

Normalization. CIS 331: Introduction to Database Systems

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

CSE-3421: Exercises. with answers

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

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

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

Normalization in OODB Design

COVERS FOR FUNCTIONAL DEPENDENCIES

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

Lecture 2 Normalization

Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES

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

Data Mining Apriori Algorithm

Boyce-Codd Normal Form

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

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]

Normalization Theory for XML

Visa Smart Debit/Credit Certificate Authority Public Keys

Flatten from/to Relational

Boolean Algebra Part 1

Chapter 3: Distributed Database Design

Discovering Data Quality Rules

Answer Key. UNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division

Chapter 9: Normalization

Data Mining: Partially from: Introduction to Data Mining by Tan, Steinbach, Kumar

Unit 3 Boolean Algebra (Continued)

Objectives, outcomes, and key concepts. Objectives: give an overview of the normal forms and their benefits and problems.

Teaching Database Modeling and Design: Areas of Confusion and Helpful Hints

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

INCIDENCE-BETWEENNESS GEOMETRY

Design of Normalized Relation: An Ameliorated Tool

Transcription:

Theory behind Normalization & DB Design Lecture 12 Satisfiability: Does an FD hold? Satisfiability of FDs Given: FD X Y and relation R Output: Does R satisfy X Y? Algorithm: a.sort R on X b.do all the tuples with equal X values agree on their Y values? Original Database Checking for the above functional dependencies Checking for above functional dependencies 1

Inference of FD s The set of all FDs on R-a brute force algorithm: Find all possible candidate FDs on attributes of R For each candidate apply the satisfiability algorithm Time consuming! Alternative: Inference Some FDs may be inferred from other FDs given: {St-Name, Course-#} Salary implies: {St-Name, Course-#, Status} Salary Basically Start from some set F of FDs Derive all possible FDs from F Based on Rules of Inference The set of all FDs derivable from F is called the closure F+ of F Armstrong s Rules of Inference Reflexive (Intuition: superset implies subset (need not be proper) (Name, Sex) ->Name (Name, Sex) ->(Name,Sex) Transitivity X Y, Y Z implies X Z Augmentation (augment both sides of the implication) (Name,Sex) Name implies (Name, Sex,Age) (Name,Age) Rules are sound and complete Produces only FD s in the closure Produces all FD s in closure 2

Augmenting Armstrong s rules Decomposition Numb {Name,Age} implies Numb Name Union X Y and X Z implies X YZ The above augment basic rules but do not add to power Dis-Prove by Counter Example Tuple 1 Tuple 2 3

Algorithm: Computing FD closures The closure F+ of F is the set of FD s inferred from F. Algorithm: F+ := F repeat apply Armstrong`s inference rules on F+ F+ := F Until F+ is not augmented end Determining closure of X (attributes) under F (set of FD s) Given F: 1.AB E 2.BE I 3.E C 4.CI D Derive {A, B}+ : a.{a, B, E} (given X) b.{a, B, E, I} (FD #2 in F) c.{a, B, E, I, C} (FD #3 in F) d.{a, B, E, I, C, D} (FD #4 in F) Requirements on Decompositions Lossless Decompisition Sometimes not possible A B C D E Given the following fd s A BCDE CD E CE B 3NF would dictate Either [A,B,C,D] & [C,D,E] Or [A,B,C,E] & [C,E,B] In either case you lose a functional dependency 4

Dependency Preserving 3NF Objective: Introduce a dependency-preserving decomposition algoritm 3NF The subset F_X of the closure F+ which uses only attributes of X is the projection of F on X A decomposition of R into R(X) and R(Y ) is dependency preserving if F+ = (FX Union FY )+ Trick is to use the minimal cover of F to drive decomposition Minimal Cover F is a minimal set of FDs if each X Y is F = {A BE, AB DE, AC G} Canonical: Y = 1 (use decomposition) A B, A E, AB D, AB-> E, AC G Left-reduced: X can t be replaced by a subset A B A E, AC G A D (How?) Non-redundant: X Y can t be removed Dependency-Preserving 3NF Decomposition Algorithm Find minimal cover Put FDs agreeing on the left-hand-side in the same schema Have extra schema for unaccounted attributes Example R = {A, B, C, D, E, G, I, J} A B A E A D AC G Resulting Schemas A B D E A C G I J NOTE THIS IS NOT THE DECOMPOSITION YOU WOULD GET USING 3NF NORMALIZATION, BUT THIS IS IN 3NF 5

Lossless Joins A Decomposition is a set of projections of relational schemas A natural join should return the original table Not Lossless! Lossless decomposition R1, R2 is a lossless join decomposition of R iff the attributes common to R1 and R2 contain a key for at least one of the involved relations 6

Dependency-Preserving Lossles-Join 3NF Decomposition Algorithm Find minimal cover Put FDs agreeing on the left-hand-side in the same schema Have extra schema for a key, if none of the above schemas contain a key R = {A, B, C, D, E, G, I, J} F = {A B, A E, A D, AC G} Resulting Schemas: A B E D A C G A C I J NOTE THIS IS THE DECOMPOSITION YOU WOULD GET USING 3NF NORMALIZATION. Facts Schemas can always employ lossless-join dependencypreserving decompositions to achieve 3NF Determining whether a relationship schema satisfies 3NF is NP-complete. Hence, automated normalization is tough. Not all violations to BCNF can be resolved through dependency-preserving decompositions MANAGER PROJECT DEPT {PROJECT, DEPT} MANAGER MANAGER DEPT Doesn t satisfy BCNF but is in 3NF BCNF decompositions can t always preserve dependencies 7