Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.

Slides:



Advertisements
Similar presentations
Functional dependencies 1. 2 Outline motivation: update anomalies cause: not expressed constraints on data (FDs) functional dependencies (FDs) definitions.
Advertisements

1 Term 2, 2004, Lecture 2, Normalisation - IntroductionMarian Ursu, Department of Computing, Goldsmiths College Normalisation Introduction.
5 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
 Definition  Components  Advantages  Limitations Contents  Definition Definition  Normal Forms Normal Forms  First Normal Form First Normal Form.
Normalisation to 3NF Database Systems Lecture 11 Natasha Alechina.
Database Systems Lecture 12 Natasha Alechina
NORMALIZATION. Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations.
Normalisation The theory of Relational Database Design.
Ch 10, Functional Dependencies and Normal forms
+ Review: Normalization and data anomalies CSCI 2141 W2013 Slide set modified from courses.ischool.berkeley.edu/i257/f06/.../Lecture06_257.ppt.
Jump to first page Normalization Jump to first page Topics n Why normalization is needed n What causes anomalies n What the 4 normal forms are n How.
Need for Normalization
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Boyce-Codd Normal Form Kelvin Nishikawa SE157a-03 Fall 2006 Kelvin Nishikawa SE157a-03 Fall 2006.
CS263:Revision on Normalisation
Normalization of Database Tables
Normalization of Database Tables
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Normalization Quiz Tao Li Grant Horntvedt. 1. Which of the following statements is true: a. Normal forms can be derived by inspecting the data in various.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 29 – 04 – 2005.
Week 6 Lecture Normalization
DBSQL 4-1 Copyright © Genetic Computer School 2009 Chapter 4 Database Design.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 3 Objectives: Identifying and Eliminating Database.
Lecture 12 Inst: Haya Sammaneh
Avoiding Database Anomalies
Normalization. 2 Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification of various types of update anomalies.
Module Title? DBMS Normalization. Module Title? DBMS Normalization  Normalization is the process of removing redundant data from tables in order to improve.
RDBMS Concepts/ Session 3 / 1 of 22 Objectives  In this lesson, you will learn to:  Describe data redundancy  Describe the first, second, and third.
Concepts of Database Management, Fifth Edition
Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables.
The Relational Model and Normalization R. Nakatsu.
Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang.
Your name here. Improving Schemas and Normalization What are redundancies and anomalies? What are functional dependencies and how are they related to.
Data Normalization Normal is not something to aspire to, it's something to get away from. ~ Jodie Foster ~
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
Switch off your Mobiles Phones or Change Profile to Silent Mode.
CORE 2: Information systems and Databases NORMALISING DATABASES.
1 5 Normalization. 2 5 Database Design Give some body of data to be represented in a database, how do we decide on a suitable logical structure for that.
Lecture No 14 Functional Dependencies & Normalization ( III ) Mar 04 th 2011 Database Systems.
Database Design – Lecture 8
Normalization Transparencies 1. ©Pearson Education 2009 Objectives How the technique of normalization is used in database design. How tables that contain.
©NIIT Normalizing and Denormalizing Data Lesson 2B / Slide 1 of 18 Objectives In this section, you will learn to: Describe the Top-down and Bottom-up approach.
In this session, you will learn to: Describe data redundancy Describe the first, second, and third normal forms Describe the Boyce-Codd Normal Form Appreciate.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Normalization. 2 u Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data,
Normalisation RELATIONAL DATABASES.  Last week we looked at elements of designing a database and the generation of an ERD  As part of the design and.
The Normal Forms 3NF and BCNF
Brian Thoms.  Databases normalization The systematic way of ensuring that a database structure is suitable for general-purpose querying and free of certain.
IST Database Normalization Todd Bacastow IST 210.
April 20022CS3X1 Database Design Normalisation (1) John Wordsworth Department of Computer Science The University of Reading Room.
NORMALIZATION: ‘1NF’ The general rule: ‘’Any field which can have many, must have its own table’’ By Sam Beaumont.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
Week 4 Lecture Part 1 of 3 Normalization of Database Tables Samuel ConnSamuel Conn, Asst. Professor.
Southern Methodist University CSE CSE 2337 Introduction to Data Management Chapter 5 Part II.
Database Architecture Normalization. Purpose of Normalization A technique for producing a set of relations with desirable properties, given the data requirements.
NORMALIZATION Handout - 4 DBMS. What is Normalization? The process of grouping data elements into tables in a way that simplifies retrieval, reduces data.
Logical Database Design and Relational Data Model Muhammad Nasir
Normalization Or theoretical and common sense approaches to redesigning a database.
SLIDE 1IS 257 – Fall 2006 Normalization Normalization theory is based on the observation that relations with certain properties are more effective.
Relational Data Model, Review Relation Tuple Attribute Domains Candidate key, primary key Key attribute, non-key attribute.
Lecture # 17 Chapter # 10 Normalization Database Systems.
Normal Forms 1NF – A table that qualifies as a relation is in 1NF. (Back)(Back) 2NF – A relation is in 2NF if all of its nonkey attributes are dependent.
Normalization.
A brief summary of database normalization
Database Normalization
Normalization.
Normalisation to 3NF.
Presentation transcript:

Normalisation 1NF to 3NF Ashima Wadhwa

In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third Normal Forms

Normalization Normalization is the process of efficiently organizing data in a database with two goals in mind First goal: eliminate redundant data for example, storing the same data in more than one table Second Goal: ensure data dependencies make sense for example, only storing related data in a table

Benefits of Normalization Less storage space Quicker updates Less data inconsistency Clearer data relationships Easier to add data Flexible Structure

The Solution: Normal Forms Bad database designs results in: redundancy: inefficient storage. anomalies: data inconsistency, difficulties in maintenance 1NF, 2NF, 3NF, BCNF are some of the early forms in the list that address this problem

Redundancy and Anomalies Redundant data Can be determined from other data in the database Leads to various problems INSERT anomalies UPDATE anomalies DELETE anomalies

First Normal Form In most definitions of the relational model All data values should be atomic This means that table entries should be single values, not sets or composite objects

First Normal Form A relation is said to be in first normal form (1NF) if all data values are atomic

Normalisation to 1NF Unnormalised Module Dept Lecturer Texts M1 D1 L1 T1, T2 M2 D1 L1 T1, T3 M3 D1 L2 T4 M4 D2 L3 T1, T5 M5 D2 L4 T6 1NF Module Dept Lecturer Text M1 D1 L1 T1 M1 D1 L1 T2 M2 D1 L1 T1 M2 D1 L1 T3 M3 D1 L2 T4 M4 D2 L3 T1 M4 D2 L3 T5 M5 D2 L4 T6 To convert to a 1NF relation, split up any non-atomic values

Problems in 1NF INSERT anomalies Can't add a module with no texts UPDATE anomalies To change lecturer for M1, we have to change two rows DELETE anomalies If we remove M3, we remove L2 as well 1NF Module Dept Lecturer Text M1 D1 L1 T1 M1 D1 L1 T2 M2 D1 L1 T1 M2 D1 L1 T3 M3 D1 L2 T4 M4 D2 L3 T1 M4 D2 L3 T5 M5 D2 L4 T6

Functional Dependencies Redundancy is often caused by a functional dependency A functional dependency (FD) is a link between two sets of attributes in a relation We can normalise a relation by removing undesirable FDs

Functional Dependencies A set of attributes, A, functionally determines another set, B, or: there exists a functional dependency between A and B (A B), if whenever two rows of the relation have the same values for all the attributes in A, then they also have the same values for all the attributes in B.

Example {ID, modCode}  {First, Last, modName} {modCode}  {modName} {ID}  {First, Last} IDmodCodemodNameFirstLast 111G51PRGProgrammingJoeBloggs 222G51DBSDatabasesAnneSmith

FDs and Normalisation We define a set of 'normal forms‘ Each normal form has fewer FDs than the last Since FDs represent redundancy, each normal form has less redundancy than the last

FDs and Normalisation Not all FDs cause a problem We identify various sorts of FD that do Each normal form removes a type of FD that is a problem We will also need a way to remove FDs

2 NF Second normal form: A relation is in second normal form (2NF) if it is in 1NF and no non-key attribute is partially dependent on a candidate key.

Second Normal Form 1NF is not in 2NF We have the FD {Module, Text}  {Lecturer, Dept} But also {Module}  {Lecturer, Dept} And so Lecturer and Dept are partially dependent on the primary key 1NF Module Dept Lecturer Text M1 D1 L1 T1 M1 D1 L1 T2 M2 D1 L1 T1 M2 D1 L1 T3 M3 D1 L2 T4 M4 D2 L3 T1 M4 D2 L3 T5 M5 D2 L4 T6

1NF to 2NF – Example 1NF Module Dept Lecturer Text M1 D1 L1 T1 M1 D1 L1 T2 M2 D1 L1 T1 M2 D1 L1 T3 M3 D1 L2 T4 M4 D2 L3 T1 M4 D2 L3 T5 M5 D2 L4 T6 2NFa Module Dept Lecturer M1 D1 L1 M2 D1 L1 M3 D1 L2 M4 D2 L3 M5 D2 L4 2NFb Module Text M1 T1 M1 T2 M2 T1 M2 T3 M3 T4 M4 T1 M4 T5 M1 T6

Problems Resolved in 2NF Problems in 1NF INSERT – Can't add a module with no texts UPDATE – To change lecturer for M1, we have to change two rows DELETE – If we remove M3, we remove L2 as well In 2NF the first two are resolved, but not the third one 2NFa Module Dept Lecturer M1 D1 L1 M2 D1 L1 M3 D1 L2 M4 D2 L3 M5 D2 L4

Problems Remaining in 2NF INSERT anomalies Can't add lecturers who teach no modules UPDATE anomalies To change the department for L1 we must alter two rows DELETE anomalies If we delete M3 we delete L2 as well 2NFa Module Dept Lecturer M1 D1 L1 M2 D1 L1 M3 D1 L2 M4 D2 L3 M5 D2 L4

Transitive FDs 3NF Transitive FDs: A FD, A  C is a transitive FD, if there is some set B such that A  B and B  C are non-trivial FDs A  B non-trivial means: B is not a subset of A We have A  B  C

3NF Third normal form : A relation is in third normal form (3NF) if it is in 2NF and no non-key attribute is transitively dependent on a candidate key.

Third Normal Form 2NFa is not in 3NF We have the FDs {Module}  {Lecturer} {Lecturer}  {Dept} So there is a transitive FD from the primary key {Module} to {Dept} 2NFa Module Dept Lecturer M1 D1 L1 M2 D1 L1 M3 D1 L2 M4 D2 L3 M5 D2 L4

2NF to 3NF – Example 2NFa Module Dept Lecturer M1 D1 L1 M2 D1 L1 M3 D1 L2 M4 D2 L3 M5 D2 L4 3NFa Lecturer Dept L1 D1 L2 D1 L3 D2 L4 D2 3NFb Module Lecturer M1 L1 M2 L1 M3 L2 M4 L3 M5 L4

Problems Resolved in 3NF Problems in 2NF INSERT – Can't add lecturers who teach no modules UPDATE – To change the department for L1 we must alter two rows DELETE – If we delete M3 we delete L2 as well In 3NF all of these are resolved (for this relation – but 3NF can still have anomalies!) 3NFa Lecturer Dept L1 D1 L2 D1 L3 D2 L4 D2 3NFb Module Lecturer M1 L1 M2 L1 M3 L2 M4 L3 M5 L4

Thanks !!