Database Design – Lecture 8

Slides:



Advertisements
Similar presentations
Chapter 5 Normalization of Database Tables
Advertisements

Database Tables and Normalization
5 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Normalization of Database Tables
Chapter 5 Normalization of Database Tables
Chapter 5 Normalization of Database Tables
DBS201: Introduction to Normalization
1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Chapter 5 Normalization of Database Tables
Normalization of Database Tables Special adaptation for INFS-3200
Normalization of Database Tables
Need for Normalization
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
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.
4 Chapter 4 Normalization Hachim Haddouti. 4 Hachim Haddouti, CH4, see also Rob & Coronel 2 In this chapter, you will learn: What normalization is and.
Normalization of Database Tables
Normalization of Database Tables
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 5 Normalization of Database Tables
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
5 Chapter 5 Normalization of Database Tables Example Database Systems: Design, Implementation, and Management, Rob and Coronel Special adaptation for INFS-3200.
NORMALIZATION N. HARIKA (CSC).
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Chapter 5 Normalization of Database Tables
Text & Original Presentations
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
Avoiding Database Anomalies
Database Systems: Design, Implementation, and Management Tenth Edition
Concepts of Database Management, Fifth Edition
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables.
The Relational Model and Normalization R. Nakatsu.
1 DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation.
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.
Database Design – Lecture 5 Conceptual Data Modeling – adding attributes.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management Peter Rob & Carlos Coronel.
Database Principles: Fundamentals of Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables Carlos Coronel, Steven.
Normalization of Database Tables
Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building.
E-R Modeling: Table Normalization. Normalization of DB Tables Normalization ► Process for evaluating and correcting table structures determines the optimal.
9/23/2012ISC329 Isabelle Bichindaritz1 Normalization.
Database Design – Lecture 6 Moving to a Logical Model.
Normalization Example. Database Systems, 8 th Edition 2 Database Tables and Normalization Normalization –Process for evaluating and correcting table structures.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
Entity Relationship Model: E-R Modeling 1 Database Design.
Database Design – Lecture 7
3 Spring Chapter Normalization of Database Tables.
Database Systems, 8 th Edition Improving the Design Table structures cleaned up to eliminate initial partial and transitive dependencies Normalization.
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.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.
Lecture 4: Logical Database Design and the Relational Model 1.
Week 4 Lecture Part 1 of 3 Normalization of Database Tables Samuel ConnSamuel Conn, Asst. Professor.
5 1 Normalization of Database Tables. 5 2 Database Tables and Normalization Normalization –Process for evaluating and correcting table structures to minimize.
NORMALIZATION Handout - 4 DBMS. What is Normalization? The process of grouping data elements into tables in a way that simplifies retrieval, reduces data.
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Normalizing Database Designs. 2 Objectives In this chapter, students will learn: –What normalization is and what role it plays in the database design.
Normalization.
Chapter 5: Relational Database Design
Chapter 4: Relational Database Design
Normalization of Database Tables PRESENTED BY TANVEERA AKHTER FOR BCA 2ND YEAR dated:15/09/2015 DEPT. OF COMPUTER SCIENCE.
Chapter 6 Normalization of Database Tables
Normalization of Database Tables Uploaded by: mysoftbooks.ml
Normalization of DB relations examples Fall 2015
Review of Week 3 Relation Transforming ERD into Relations
Presentation transcript:

Database Design – Lecture 8 Normalization

Lecture Objectives Review basic rules for converting Entities to Tables Review how to address Relationships between entities Overview of Normalization

Converting ERD into Relational Database Model Entities to Tables Create a separate table for each entity and consider all the attributes you defined in ERD as the table columns Define a unique identifier as the table PK. Could be an existing attribute that can be used for PK otherwise create a generic PK. Do not include derived attributes in the tables. Ensure all attributes are atomic. Create a new table to support multi-valued attributes.

Converting ERD into Relational Database Model Relationships For 1:M connectivity, include the PK of the ’1’ as an FK attribute in the ‘M’ table. Add additional attributes to the ‘M’ table, as required. For M:N connectivity, create a bridge table. Include the PKs from both entities as a composite PK in the bridge table. These attributes will also be FKs in the bridge table. Add additional attributes to the bridge table, as required.

Converting ERD into Relational Database Model Relationships For Strong-Weak relationship, include PK of strong entity as part of the PK of the weak entity, thus giving it a composite primary key. It will also be an FK in the weak entity. For Supertype/Subtype relationships, create a new entity. Attributes unique to the subtype are moved to the new table and are removed from the supertype entity. Both entities will have the same primary keys.

Converting ERD into Relational Database Model Relationships For recursive relationships (1:1, 1:M), add additional attributes as required. For M:N recursive relationship, create a new entity with a composite primary key. Create a primary key for the new entity and make a composite primary key using it and the primary key from the ‘1’ entity. The primary key from the ‘1’ will also be a FK in the new entity.

Normalization Normalization can be used in two ways: As a process to validate the table structures created through the conversion of entity relationship diagrams to relational tables As a process to create entities from table structures created by user views

Normalization Normalization is a process for assigning attributes to entities Reduces data redundancies Helps eliminate data anomalies Produces controlled redundancies to link tables Works through a series of stages called normal forms Works with views of data

Database Tables and Normalization Normalization stages 1NF - First normal form Eliminate repeating groups Identify PK  result is functional dependency 2NF - Second normal form Eliminate partial dependencies 3NF - Third normal form Eliminate transitive dependencies BCNF – Boyce-Codd normal form Eliminate dependencies whereby a non-key attribute can identify a key attribute.

Need for Normalization possible primary keys? Table entries have data inconsistencies (note blank entries) Table displays data anomalies: Update - Modifying JOB_CLASS Insertion - New employee must be assigned project Deletion – If an employee is deleted, other vital data lost Figure 5.2

Conversion to 1NF Repeating groups must be eliminated Proper primary key developed Uniquely identifies attribute values - rows (functional dependency)

Data Organization: 1NF Figure 5.2 Eliminate repeating groups – populate every cell of the ‘table’.

Conversion to 1NF Identify dependencies Desirable dependencies based on primary key Less desirable dependencies Partial (later) based on part of composite primary key Transitive (later) one nonprime attribute depends on another nonprime attribute

Dependency Diagram (1NF) First Normal Form: identify dependencies Partial Dependency: attributes dependent on part of the primary key A B C d e f Transitive Dependency (non-key attribute depends on another non-key attribute) Note: Capital letters refer to primary key, lower case letters refer to attributes.

Dependency Diagram (1NF) First Normal Form: identify all dependencies Partial Dependency: attributes dependent on part of the primary key A B C d e f Functional Dependency: A, B, C, d, e, f Partial Dependency: A, d, e Transitive Dependency: d, f Transitive Dependency (non-key attribute depends on another non-key attribute)

Data Organization: 1NF Figure 5.2 Eliminate repeating groups – populate every cell of the ‘table’.

Dependency Diagram (1NF) PROJ_NUM EMP_NUM PROJ_NAME EMP_NAME JOB_CLASS CHG_HOUR HOURS Functional Dependency: each attribute is uniquely identified by, or is dependent on the primary key. Primary key is a composite primary key and is made up of PROJ_NUM and EMP_NUM EMPLOYEE_PROJECT (PROJ_NUM (pk), EMP_NUM (pk), PROJ_NAME, EMP_NAME, JOB_CLASS, CHG_HOUR, HOURS)

1NF Summarized All key attributes defined No repeating groups in table All attributes dependent on primary key (functional dependency) EMPLOYEE_PROJECT (PROJ_NUM (pk), EMP_NUM (pk), PROJ_NAME, EMP_NAME, JOB_CLASS, CHG_HOUR, HOURS)

Dependency Diagram Continued 1NF 2NF PROJ_NUM EMP_NUM PROJ_NAME EMP_NAME JOB_CLASS CHG_HOUR HOURS

Conversion to 2NF Start with 1NF format: Write each key component on separate line Write original key on last line Each component is new table Write dependent attributes after each key PROJECT (PROJ_NUM (pk), PROJ_NAME) EMPLOYEE (EMP_NUM (pk), EMP_NAME, JOB_CLASS, CHG_HOUR) EMPLOYEE_PROJECT (PROJ_NUM (pk, fk), EMP_NUM (pk, fk), HOURS) Attribute of hours is dependent on composite primary key

2NF Summarized In 1NF Includes no partial dependencies Attributes dependent on a portion of primary key Still possible to exhibit transitive dependency Attributes may be functionally dependent on non-key attributes

Dependency Diagram Continued 3NF 1NF 2NF PROJ_NUM EMP_NUM PROJ_NAME EMP_NAME JOB_CLASS CHG_HOUR HOURS

Conversion to 3NF Create separate tables to eliminate transitive functional dependencies Identify any additional attributes needed in new table JOB (JOB_CLASS (pk), JOB_DESCRIPTION, CHG_HOUR) PROJECT (PROJ_NUM (pk), PROJ_NAME) EMPLOYEE (EMP_NUM (pk), EMP_NAME, JOB_CLASS (fk)) EMPLOYEE_PROJECT (PROJ_NUM (pk, fk), EMP_NUM (pk, fk), HOURS) New attribute

3NF Summarized In 2NF Contains no transitive dependencies

Normalization and Database Design Normalization should be part of the design process E-R Diagram provides macro view Normalization provides micro view of entities Focuses on characteristics of specific entities May yield additional entities Difficult to separate normalization from E-R diagramming Business rules must be determined

Normalization Steps 1NF 2NF All key attributes are defined No repeating groups All attributes are functionally dependent on the primary key 2NF Table is in 1NF No partial dependencies

Normalization Steps 3NF Table is in 2NF No transitive dependencies New PKs identified where appropriate