Database Normalization.

Slides:



Advertisements
Similar presentations
Chapter 5 Normalization of Database Tables
Advertisements

Relational Terminology. Normalization A method where data items are grouped together to better accommodate business changes Provides a method for representing.
Normalization What is it?
Normalization ISYS 464. Database Design Based on ERD Strong entity: Create a table that includes all simple attributes –Composite Weak entity: add owner.
Normalization Dr. Mario Guimaraes. Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints.
Data Modeling and Relational Database Design ISYS 650.
Accounting 6500 Relational Databases: Accounting Applications Introduction to Normalization.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Chapter 5 Normalization of Database Tables
Project and Data Management Software
Normalization A337. A337 - Reed Smith2 Structure What is a database? ◦ Tables of information  Rows are referred to as records  Columns are referred.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Chapter 4: Logical Database Design and the Relational Model (Part II)
Week 6 Lecture Normalization
Lecture 12 Inst: Haya Sammaneh
Avoiding Database Anomalies
RDBMS Concepts/ Session 3 / 1 of 22 Objectives  In this lesson, you will learn to:  Describe data redundancy  Describe the first, second, and third.
The Relational Model and Normalization R. Nakatsu.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
In this chapter, you learn about the following: ❑ Anomalies ❑ Dependency and determinants ❑ Normalization ❑ A layman’s method of understanding normalization.
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
BIS 360 – Lecture Eight Ch. 12: Database Design and Normalization.
Customer Order Order Number Date Cust ID Last Name First Name State Amount Tax Rate Product 1 ID Product 1 Description Product 1 Quantity Product 2 ID.
Unit 4 Object Relational Modeling. Key Concepts Object-Relational Modeling outcomes and process Relational data model Normalization Anomalies Functional.
Database Design – Lecture 8
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.
Lecture Nine: Normalization
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
Logical Database Design and the Relational Model.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Normalization Hour1,2 Presented & Modified by Mahmoud Rafeek Alfarra.
6-1 © Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Chapter 8: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer.
8-1 © Prentice Hall, 2007 Chapter 8: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Lecture 4: Logical Database Design and the Relational Model 1.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
Normalization ACSC 425 Database Management Systems.
NORMALIZATION Handout - 4 DBMS. What is Normalization? The process of grouping data elements into tables in a way that simplifies retrieval, reduces data.
Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Chapter 4: Logical Database Design and the Relational Model Modern Database Management.
What Is Normalization  In relational database design, the process of organizing data to minimize redundancy  Usually involves dividing a database into.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Normalization ISYS 464. Database Design Based on ERD Strong entity: Create a table that includes all simple attributes –Composite Weak entity: add owner.
Logical Design & the Relational Model
Chapter 8: Object-Relational Modeling
Relational Schema Design II
Normalization (Database Design)
INLS 623 – Database Normalization
Normalization Karolina muszyńska
Chapter 5: Logical Database Design and the Relational Model
Functional Dependencies
Payroll Management System
Unit 4: Normalization of Relations
Normalization Refine data To attain a good DB design
Database Normalization
Chapter 6 Normalization of Database Tables
Normalization Murali Mani.
Normalization A337.
Normalization and Databases
Normalization Dale-Marie Wilson, Ph.D..
Normalization.
Normalization Normalization theory is based on the observation that relations with certain properties are more effective in inserting, updating and deleting.
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Relational Database Design
Database Normalisation
Sampath Jayarathna Cal Poly Pomona
Database Normalization.
Database Normalization
Presentation transcript:

Database Normalization

Database Normalization What are the problems here?

Database Normalization Entity Attributes and their types Redundant Data Anomaly and its types Normalization and its forms

Any thing about which data is stored. Normalization Entity Any thing about which data is stored. Examples: Person, Company, Event

An entity is represented by a set of attributes. Normalization Entity Property of an entity An entity is represented by a set of attributes. field

Example Attributes Entity STUDENT Student Id Name Address Phone No STUDENT Entity

Attribute Types Simple(component) attributes Composite attributes Single-valued attributes Multi-valued attributes Derived attributes Key attributes Non-Key attributes

Which one is Composite Attribute? Name First Name Middle Name Last Name Which one is Composite Attribute?

Domain The set (range) of allowed values for an attribute Roll No. Grade 1 A 2 B 3 F 4 C Domain for Grade attribute { A, B, C, D, F }

Redundant Data Employee Table EMPID NAME DEPT SALARY COURSE GRADE 100 Asad Marketing 42000 IT A 140 Waheed Accounting 39000 Management B 110 Majid Info Systems 41500 DBMS

An anomaly is an inconsistent or contradictory state of the database.

Anomalies Types of Anomalies Insertion Anomaly Deletion Anomaly Update Anomaly

Insertion Anomaly Occurrence of an error or inconsistency due to the insertion of new data in a table

Example Insertion Anomaly Employee Table EMPID NAME DEPT SALARY COURSE GRADE 100 Asad Marketing 42000 IT A 140 Waheed Accounting 39000 … 110 Majid Info Systems 41500 DBMS 4000 Management B

Deletion Anomaly A valid fact is lost when a record is deleted. Occurrence of an error or inconsistency due to the deletion of data in a table A valid fact is lost when a record is deleted.

Example Deletion Anomaly Employee Table EMPID NAME DEPT SALARY COURSE GRADE 100 Asad Marketing 42000 SPSS A Management B 140 Waheed Accounting 39000 110 Majid Info Systems 41500 Intro. to IT

Update Anomaly One occurrence of a fact is changed, Occurrence of an error or inconsistency due to the modification of data in a table One occurrence of a fact is changed, but not all occurrences.

Example Update Anomaly Employee Table EMPID NAME DEPT SALARY COURSE GRADE 100 Asad Marketing 42000 SPSS A 140 Waheed Accounting 39000 … 110 Majid Info Systems 41500 Intro. to IT B 45000 Management

Normalization Basic Idea 1. Divide a table into two or more tables and 2. Define relationships between the tables. Objectives Minimize data duplication Efficient data retrieval Less space Less errors

Normalization Two basic conditions No redundant data No anomalies.

1st three levels often used Normal Forms 7 Levels / Stages of normalization 1st three levels often used

7 Normal Forms Unnormalized data Normalized data 1NF 2NF 3NF BCNF 4NF 5NF (PJNF) DKNF Normalized data

Steps in normalization Remove Table with repeating groups Repeating Groups 1st Normal Form Partial Dependencies 2nd Normal Form Transitive Dependencies 3rd Normal Form Determinant / Candidate Keys Boyce-Codd Normal Form Multivalued Dependencies 4th Normal Form Removing Remaining anomalies 5th Normal Form (Project Join NF) Removing Remaining anomalies Domain Key Normal Form

Result Card Card No.: 1 Issue date: 3/4/8 Example Card No.: 1 Issue date: 3/4/8 Student ID: 111 Student Name: ABC Student Address: 45-C, Lahore. Course ID Course Name Total Marks Obtained Marks 101 W 100 70 102 X 50 103 Y 80 104 Z 60 1st Grand Total: 260 Representation

Before Normalization Redundant Data 2nd Representation Crd_No Is_Date S_ID SName Addr C_ID C_Name TMrks OMrks GTtl 1 3/4/8 111 ABC 45-C 101 W 100 70 260 102 X 50 103 Y 80 104 Z 60 2 95 MNO 40-D 230 … Redundant Data 2nd Representation

There are no repeating attribute-groups. Normal Form 1st There are no repeating attribute-groups.

Before Normalization Best Approach 3rd Representation 1 3/4/8 111 ABC CrdNo IsDate SId SName Adr CId CName TMrks OMrks GTtl 1 3/4/8 111 ABC 45C 101 W 100 70 102 X 50 103 Y 80 260 2 95 MNO 40D 104 Z 60 230 … Best Approach 3rd Representation

Before Normalization 4th Representation Crd_No Is_Date S_ID SName Addr C_ID C_Name TMrks OMrks GTtl 1 3/4/8 111 ABC 45-C 101 W 100 70 260 102 X 50 103 Y 80 104 Z 60 2 95 MNO 40-D 230 … Crd_No Is_Date S_ID SName Addr C_ID C_Name TMrks OMrks GTtl 1 3/4/8 111 ABC 45-C 101 W 100 70 260 2 95 MNO 40-D 103 Y 230 … 102 X 100 50 103 Y 100 80 104 Z 100 60 104 Z 100 60 4th Representation

Normal Form 1st Process Identify the primary key of denormalized table. Repeating attribute-groups of the table are separated out in form of a new table. Primary key of old table is added into new table as foreign key. Identify the primary key of new table.

Repeating Attributes Card No.: 1 Issue date: 3/4/8 Student ID: 111 Student Name: ABC Student Address: 45-C, Lahore. Course ID Course Name Total Marks Obtained Marks 101 W 100 70 102 X 50 103 Y 80 104 Z 60 Grand Total: 260 Repeating attribute-groups

Repeating Attributes Grand Total: 260 5th Card No.: 1 Issue date: 3/4/8 Student ID: 111 Student Name: ABC Student Address: 45-C, Lahore. Course ID Course Name Total Marks Obtained Marks 101 W 100 70 Course ID Course Name Total Marks Obtained Marks 102 X 100 50 Course ID Course Name Total Marks Obtained Marks 103 Y 100 80 Course ID Course Name Total Marks Obtained Marks 104 Z 100 60 5th Grand Total: 260 Representation

} Normal Form 1st Card No PK Issue Date Student ID Student Name Student Address Grand Total Card No FK Course ID Course Name Total Marks Obtained Marks } CP Table-2 Table-1

} Normal Form 1st Card No PK Issue Date Student ID Student Name Student Address Grand Total Card No FK Course ID Course Name Total Marks Obtained Marks } CP Table-2 Table-1

There is no partial dependency. Normal Form 2nd There is no partial dependency. part  partial Partial dependency: An attribute depends upon the part of the key, but not on the whole key.

Normal Form 2nd Relation is in 1NF. Conditions Relation is in 1NF. All non-key attributes should depend upon Key attribute. Implementable if Compound Key Exist.

Normal Form 2nd Process All non-key attributes that depend upon part of key are separated out in a new table along with part of key on which these attributes depend. Identify the primary key of new table and add it back to the old table as foreign key.

} Normal Form 2nd Card No FK Course ID CP Course Name Total Marks Obtained Marks } CP

}CP } Normal Form 2nd Card No FK Course ID Course Name Total Marks Obtained Marks } CP }CP Card No FK Course ID FK Obtained Marks Course ID PK Course Name Total Marks

There is no transitive dependency. Normal Form 3rd There is no transitive dependency. Transitive dependency: A non-key attribute depends upon another non-key attribute.

Normal Form 3rd Relation is in 2NF. Conditions Relation is in 2NF. All non-key attributes depend on key attribute.

Normal Form 3rd Process All non-key attributes depending on any non-key attribute are separated out in form of new table. Identify the primary key of new table and add it back to the old table as foreign key.

Normal Form 3rd Card No PK Issue Date Student ID FK Card No PK Grand Total Card No PK Issue Date Student ID Student Name Student Address Grand Total Student ID PK Student Name Student Address Any thing wrong here?

}CP Normalization Over all Result Card No FK Course ID FK Obtained Marks }CP Card No PK Issue Date Student ID FK Grand Total Student ID PK Student Name Student Address Course ID PK Course Name Total Marks

Invoice Practice Exercise Invoice no.: 1 Invoice date: 3/4/8 Customer ID: 111 Customer Name: ABC Customer Address: 45-C, Lahore Phone : 33333333 P_ID P_Name QTY Price Total 101 W 3 20 60 102 X 2 10 103 Y 30 104 Z 1 Invoice Total: 200