Edited by: Nada Alhirabi. Normalization

Similar documents
In-Sem Paper Solution Subject: Database Management System (2015 Patter) August, Answer: [1]

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

Normalization in DBMS

Redundancy:Dependencies between attributes within a relation cause redundancy.

DATABASE DESIGN I - 1DL300

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

CMU SCS CMU SCS CMU SCS CMU SCS whole nothing but

Normalization Normalization

Database Systems. Normalization Lecture# 7

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

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 6 Normalization of Database Tables

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

Database Normalization. (Olav Dæhli 2018)

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

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

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

Lecture 3. Wednesday, September 3, 2014

Database Design Theory and Normalization. CS 377: Database Systems

CSIT5300: Advanced Database Systems

The Relational Model and Normalization

Normalisation. Normalisation. Normalisation

IS 263 Database Concepts

Database Tables and Normalization

UNIT 3 DATABASE DESIGN

Normalization and Functional Dependencies. CS6302 Database management systems T.R.Lekhaa, AP/IT

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

Relational Design: Characteristics of Well-designed DB

CSE 562 Database Systems

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

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

Institute of Southern Punjab, Multan

Chapter 6: Relational Database Design

Normalization Rule. First Normal Form (1NF) Normalization rule are divided into following normal form. 1. First Normal Form. 2. Second Normal Form

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

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

To overcome these anomalies we need to normalize the data. In the next section we will discuss about normalization.

Relational Database design. Slides By: Shree Jaswal

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

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

Unit 3 : Relational Database Design

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

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

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

Normalisation Chapter2 Contents

Database Design. SYS-ED / Computer Education Techniques, Inc. 1

Normalization. CMSC 461 Michael Wilson

Informal Design Guidelines for Relational Databases

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 9 Normalizing Database Designs

Relational Database Design (II)

CS 338 Functional Dependencies

Schema Refinement: Dependencies and Normal Forms

Theory of Normal Forms Decomposition of Relations. Overview

Normalization (1) IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

The Relational Data Model

Chapter 8: Relational Database Design

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

Lecture5 Functional Dependencies and Normalization for Relational Databases

Database Foundations. 3-9 Validating Data Using Normalization. Copyright 2015, Oracle and/or its affiliates. All rights reserved.

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

Chapter 7: Relational Database Design

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

Schema Refinement: Dependencies and Normal Forms

Functional Dependency

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

Functional Dependencies and Normalization

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

Functional Dependencies and Finding a Minimal Cover

CS 2451 Database Systems: Database and Schema Design

ACS-2914 Normalization March 2009 NORMALIZATION 2. Ron McFadyen 1. Normalization 3. De-normalization 3

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

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

Functional Dependencies CS 1270

Schema Refinement: Dependencies and Normal Forms

NORMAL FORMS. CS121: Relational Databases Fall 2017 Lecture 18

Case Study: Lufthansa Cargo Database

Lecture 4. Database design IV. INDs and 4NF Design wrapup

Relational Design 1 / 34

COSC Dr. Ramon Lawrence. Emp Relation

Concepts from

Part II: Using FD Theory to do Database Design

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

Normalisation. Databases: Topic 4

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

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

8) A top-to-bottom relationship among the items in a database is established by a

DBMS Chapter Three IS304. Database Normalization-Comp.

begin [atomic] operation, operation, { commit rollback} end

FIT1004 Database Topic 6: Normalisation

Normalization. Un Normalized Form (UNF) Share. Download the pdf version of these notes.

DATABASE DESIGN I - 1DL300

Lecture 11 - Chapter 8 Relational Database Design Part 1

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

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

DATABASE MANAGEMENT SYSTEMS

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

CS252:HACD Fundamentals of Relational Databases Notes for Section 9: Database Design Issues, Part II

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

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

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

Birkbeck. (University of London) BSc/FD EXAMINATION. Department of Computer Science and Information Systems. Database Management (COIY028H6)

Transcription:

Edited by: Nada Alhirabi Normalization

Normalization:Why do we need to normalize? 1. To avoid redundancy (less storage space needed, and data is consistent) Ssn c-id Grade Name Address 123 cs331 A smith Main 123 cs351 B smith Main 2. To avoid update/delete anomalies Ssn c-id Grade Name Address 123 cs33 1A smith Main 234 null null jones Forbes Insertion anomaly: Cannot make a record Jones address because he is not taking any classes 2

Normal Forms First Normal Form 1NF Second Normal Form 2NF Only those are covered Third Normal Form 3NF: In practice, normalized means in BCNF or 3NF Fourth Normal Form 4NF Fifth Normal Form 5NF Boyce-Codd Normal Form BCNF 3

First Normal Form (1NF) 1NF: all attributes are atomic ( no repeating groups ) Last Name Smith Greg First Name Peter Mary John Anne Michael Not in 1NF Normalized to 1NF Last First Name Name Smith Peter Smith Mary Smith John Greg Anne Greg Michael 4

Second Normal Form (2NF) 2NF: 1NF and all non-key attributes are fully dependent on the PK ( no partial dependencies ) Student Course_ID Grade Address Erik CIS331 A 80 Ericsson Av. Sven CIS331 B 12 Olafson St. Inge CIS331 C 192 Odin Blvd. Hildur CIS362 A 212 Reykjavik St. Not in 2NF 5

Second Normal Form (2NF) Student Erik Sven Inge Hildur Address 80 Ericsson Av. 12 Olafson St. 192 Freya Blvd. 212 Reykjavik St. Normalized to 2NF Student Course_ID Grade Erik CIS331 A Sven CIS331 B Inge CIS331 C Hildur CIS362 A 6

Third Normal Form (3NF) 3NF: 2NF and no transitive dependencies Transitivity: If A à B and B à C, then A à C Student Course_ID Grade Grade_value Erik CIS331 A 4.00 Sven CIS331 B 3.00 Inge CIS331 C 2.00 Not in 3NF Hildur CIS362 A 4.00 7

Third Normal Form (3NF) Student Course_ID Grade Erik CIS331 A Sven CIS331 B Inge CIS331 C Hildur CIS362 A Grade Grade_value A 4.00 B 3.00 C 2.00 Normalized to 3NF 8

Extra examples Example1: Suppose a company wants to store the names and contact details of its employees. It creates a table that looks like this: Two employees (Jon & Lester) are having two mobile numbers so the company stored them in the same field as you can see in the table above.

1NF: each attribute of a table is atomic This table is not in 1NF as the rule says each attribute of a table must have atomic (single) values, ( the emp_mobile values for employees Jon & Lester violates that rule.) To make the table complies with 1NF we should have the data like this:

Second normal form (2NF) Example2: Suppose a school wants to store the data of teachers and the subjects they teach. They create a table that looks like this: Since a teacher can teach more than one subjects, the table can have multiple rows for a same teacher. Candidate Keys: {teacher_id, subject} Non prime attribute: teacher_age The table is in 1 NF because each attribute has atomic values. However, it is not in 2NF because non prime attribute teacher_age is dependent on teacher_id alone which is a proper subset of candidate key. This violates the rule for 2NF as the rule says no non-prime attribute is dependent on the proper subset of any candidate key of the table.

To make the table complies with 2NF we can break it in two tables like this:

Third Normal form (3NF) Example3: Suppose a company wants to store the complete address of each employee, they create a table named employee_details that looks like this: Super keys: {emp_id}, {emp_id, emp_name}, {emp_id, emp_name, emp_zip} so on Candidate Keys: {emp_id} Non-prime attributes: all attributes except emp_id are non-prime as they are not part of any candidate keys. Here, emp_state, emp_city & emp_district dependent on emp_zip. And, emp_zip is dependent on emp_id that makes non-prime attributes (emp_state, emp_city & emp_district) transitively dependent on super key (emp_id). This violates the rule of 3NF.

To make this table complies with 3NF we have to break the table into two tables to remove the transitive dependency:

Normalization: Final Thoughts There are higher normal forms (4NF, 5NF), but we will not talk about them In practice, normalized means in BCNF or 3NF Luckily, in practice, ER diagrams lead to normalized tables (but do not rely on luck) 15

Normalization: summary Why do we normalize? To avoid redundancy (less storage space needed, and data is consistent) To avoid update/delete anomalies A good decomposition should: be a lossless join decomposition (you can recover original tables with a join) preserve dependencies (FD s should not span two tables) 1NF (all attributes are atomic) 2NF (no partial dependencies) 3NF (no transitive dependencies) 16 Source for the most slides are taken from : Vladimir Vacic, Temple University and http://beginnersbook.com/2015/05/normalization-in-dbms/ website.