Normalization ISYS 464. Database Design Based on ERD Strong entity: Create a table that includes all simple attributes –Composite Weak entity: add owner.

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.
Defined by Edgar Codd in 1970 Defined by Edgar Codd in 1970 Considered ingenious but impractical Considered ingenious but impractical Conceptually simple.
Enhanced Entity-Relationship Modeling. Strong and Weak Entity Types Strong entity: Each object is uniquely identifiable using primary key of that entity.
Normalization What is it?
Normalization Dr. Mario Guimaraes. Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints.
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.
Functional Dependencies and Normalization for Relational Databases.
Normalization of Database Tables Special adaptation for INFS-3200
Data Modeling and Relational Database Design ISYS 650.
© 2005 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Introduction to Relational Database ISYS 464. Introduction to Relational Model Data is logically structured within relations. Each relation is a table.
Data Modeling with ERD ISYS 363. Entity-Relationship Diagram An entity is a “thing” in the real world, such as a person, place, event for which we intend.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Logical Model Agenda - Informal Mapping ER-Diagram to Schemas
Normalization of Database Tables
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Data Modeling ISYS 464. Database Design Process Conceptual database design: –The process of creating a data model independent of implementation details.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
Enhanced Entity-Relationship Modeling
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Lecture4: Informal guidelines for good relational design Mapping ERD to Relation Ref. Chapter3 Lecture4 1.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Week 6 Lecture Normalization
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Concepts and Terminology Introduction to Database.
Avoiding Database Anomalies
Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)
The Relational Model and Normalization R. Nakatsu.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
Database Normalization.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall, Modified by Dr. Mathis 3-1 David M. Kroenke’s Chapter Three: The Relational.
Functional Dependencies and Normalization for Relational Databases.
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.
By Abdul Rashid Ahmad. E.F. Codd proposed three normal forms: The first, second, and third normal forms 1NF, 2NF and 3NF are based on the functional dependencies.
Introduction to Access ISYS 363. Creating a New Database MS Office button/New –Blank database –New database name and location.
Database Design – Lecture 8
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
1 Functional Dependencies and Normalization Chapter 15.
Data Modeling with ERD BUS 782. Entities An entity is a person, place, object, event, or concept in the user environment about which the organization.
Lecture 3 Functional Dependency and Normal Forms Prof. Sin-Min Lee Department of Computer Science.
Logical Database Design and the Relational Model.
Lecture4: Informal guidelines for good relational design Mapping ERD to Relation Prepared by L. Nouf Almujally Ref. Chapter3 Lecture4 1.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
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.
Lecture 4: Logical Database Design and the Relational Model 1.
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
Data Modeling with ERD ISYS 363.
Logical Database Design and Relational Data Model Muhammad Nasir
What Is Normalization  In relational database design, the process of organizing data to minimize redundancy  Usually involves dividing a database into.
Normalization ISYS 464. Database Design Based on ERD Strong entity: Create a table that includes all simple attributes –Composite Weak entity: add owner.
COP 6726: New Directions in Database Systems
Chapter 4 Logical Database Design and the Relational Model
Chapter 5: Logical Database Design and the Relational Model
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Relational Database.
Normalization.
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Sampath Jayarathna Cal Poly Pomona
Database Normalization.
Presentation transcript:

Normalization ISYS 464

Database Design Based on ERD Strong entity: Create a table that includes all simple attributes –Composite Weak entity: add owner primary key Multi-valued attribute: Create a table for each multi-valued attribute –Key + attribute Relationship: –1:1, 1:M Relationship table: for partial participation to avoid null Foreign key –M:M: relationship table –N-ary relationship: relationship table –Recursive relationship Attribute of relationship Superclass and subclass Note: The database designed according to these rules will meet the 3NF requirements.

Database design objectives Eliminate data duplication. Link related records in related tables.

Example Employee/Dependent report: EmpID: E101Ename: Peter Address: 123 XYZ St DependentNameRelationshipDOB NancyDaughter1/1/95 AlanSon12/25/03 EmpDependent Table: EmpID EmpName Address DepName Relation DepDOB E101Peter 123 XYZ St NancyD1/1/95 E101Peter 123 XYZ St AlanS12/25/03 Note: This database is able to produce the report, but has duplicated data.

Update Anomalies Due To Duplication Modification anomaly: –Inconsistent data Insertion Anomalies: –Enter an employee with no dependent –Null Deletion Anomaly: –If Nancy and Alan become independent.

If we mix multivalue attribute with regular attributes in one table Employee Table: –SSN, Ename, Sex, DOB, Phone –Employee may have more than 1 phone. Key: SSN or SSN + Phone Duplication ?

Example 2 EmpDependent table: –EmpID, Ename, Address, Depname, Relation, DepDOB Key: EmpID + Depname

If we mix two entities with 1:M relationship in one table FacultyStudent table: –Faculty Advise Student: 1:M relationship –FID, Fname, SID, Sname, SAddress Key: SID Duplication?

If we mix two entities with M:M relationship in one table StudentCourse table: –SID, Sname, GPA, CID, Cname, Units Key: SID + CID Duplication?

Normalization Decompose unsatisfactory relation into smaller relations with desirable properties. –No duplication The original relation can be recovered by applying natural join to the smaller relations. –So that no information is lost in the process. Keys and function dependency: –Which field is the key field of the EMpDependent Table? EmpID + DepName

Function Dependency Relationship between attributes X -> Y –The value of X uniquely determines the value of Y. –Y is functionally dependent on X. –A value of X is associated with only one value of Y.

Example Employee table: –SSNEnameSexDOB –S1PeterM1/1/75 –S2PaulM12/25/80 –S3MaryF7/4/72 Function Dependencies: –SSN -> Ename, SSN ->Sex, SSN -> DOB –SSN -> Ename, Sex, DOB Any other FD: –Ename -> SSN? –Ename -> Sex ? –DOB -> SSN?

What is the key of Employee table: –SSN Observations: –All non-key fields are functionally dependent on SSN. –There is no other FD. –The only FD is the key dependency. –There is no data duplication in the Employee table.

Normalization Process Inputs: –A “universal relation” –Function dependencies Output: Normalized tables Process: –Decompose the unnormalized relation into smaller relations such that in each relation the non key fields are functionally dependent on the key, the whole key, and nothing but the key. So help me Codd!

First Normal Form The fields of a relation are all simple attribute. –All relational database tables meet this requirement. EmpDependent table: –EmpID, Ename, Address, Depname, Relation, DepDOB –First normal form? Yes –Second normal form?

Second Normal Form The non-key fields are functionally dependent on the key, and the whole key. –FD: EmpID ->Ename, Address –Key: EmpID + Depname –Ename and Address depend on part of the key. Every non-key field is fully functionally dependent on the key. Decompose the EMpDependent table into two tables: –EmpID, Ename, Address –EmpID, Depname, Relation, DepDOB

Employee Table: –SSN, Ename, Sex, DOB, Phone –Employee may have more than 1 phone. FD: –SSN -> Ename, Sex, DOB, –SSN -> Phone? Key: SSN + Phone 2NF? No Decompose into two tables: –SSN, Ename, Sex, DOB –SSN, Phone

FacultyStudent table: –Faculty Advise Student: 1:M relationship –FID, Fname, Office, SID, Sname, SAddress FD: –FID -> Fname, Office –SID -> Sname, SAddress, FID, Fname, Office Key: SID 2NF ? Yes Duplication? Yes Why? –All non-key fields depend on the whole key, but not Nothing But the Key! SID -> FID, Fname, Office FID -> Fname, Office

Transitive Dependency If X -> Y, and Y->Z then X -> Z. Z if transitively dependent on the key. SID -> FID, FID -> Fname, Office –SID -> Fname, Office –Fname and Office are transitively dependent on SID.

Third Normal Form Every non-key field is: –Fully functionally dependent on the key, and –Non-transitively dependent on the key. Decompose: –FID, Fname, Office –SID, FID, Sname, SAddress

Example Customer/Orders report: CID: C101Cname: Peter Address: 123 XYZ St OIDOdateSalesPersonAmount O251/1/04John125 O302/25/04Alan500 CustomerOrders Table: CIDCName Address OID Odate SalesPerson Amount C101Peter 123 XYZ St O251/1/04John125 C101Peter 123 XYZ St O302/25/04Alan500

Example Key: OID FD: –OID -> CID, Cname, Address, Odate, SalesPerson, Amount –CID -> Cname, Address 2NF? Yes 3 NF? No Decompose: –CID, Cname, Address –OID, CID, Odate, SalesPerson, Amount

Example with 1:M Relationship FacultyStudent table: –Faculty Advise Student: 1:M relationship –FID, Fname, SID, Sname, SAddress FD: –FID -> Fname –SID -> Sname, Saddress Key: SID 2NF? Yes 3NF? No, because SID ->FID, FID -> Fname Decompose: –Table 1: FID, Fname –Tablw 2: SID, FID, Sname, SAddress

Example with M:M Relationship StudentCourse table: –SID, Sname, GPA, CID, Cname, Units Key: SID + CID Function Dependencies: –SID -> Sname, GPA –CID -> Cname, Units 2NF? No –Decompose: Table 1: SID -> Sname, GPA Table 2: CID -> Cname, Units Table 3: SID, CID 3NF? Yes

Online Shopping Cart Customer ShoppingCart Product Has 1 M M M CID Cname Addr CartIDDate Qty PID Pname Price

Normalized Database Universal Relation: –CID, Cname, Addr, CartID, Date, PID, Pname, Price, Qty Key: CartID + PID FDs: –CartID -> Date, CID, Cname, Addr –CID -> Cname, Addr –PID -> Pname, Price Normalized database: –CID, Cname, Addr –CartID, Date, CID –PID, Pname, Price –CartID, PID, Qty

Database Design Based on ERD Strong entity: Create a table that includes all simple attributes –Composite Weak entity: add owner primary key Multi-valued attribute: Create a table for each multi-valued attribute –Key + attribute Relationship: –1:1, 1:M Relationship table: for partial participation to avoid null Foreign key –M:M: relationship table –N-ary relationship: relationship table –Recursive relationship Attribute of relationship Superclass and subclass Note: The database designed according to these rules will meet the 3NF requirements.

Denormalization The refinement to the relational schema such that the degree of normalization for a modified relation is less than the degree of at least one of the original relations. Objective: –Speed up processing