資料庫正規化 Database Normalization 取材自 AIS, 6 th edition By Gelinas et al.

Slides:



Advertisements
Similar presentations
Relational Terminology. Normalization A method where data items are grouped together to better accommodate business changes Provides a method for representing.
Advertisements

Fundamentals, Design, and Implementation, 9/e Chapter 4 The Relational Model and 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.
The Relational Database Model:
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design: Normalization.
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 A337. A337 - Reed Smith2 Structure What is a database? ◦ Tables of information  Rows are referred to as records  Columns are referred.
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design 1: Normalization.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Chapter 3 The Relational Model and Normalization
Normalization Rules for Database Tables Northern Arizona University College of Business Administration.
Chapter 5 Normalization of Database Tables
Normalization of Tables “Between two evils, choose neither; between two goods, choose both.” Tryon Edwards.
Chapter 4: Logical Database Design and the Relational Model (Part II)
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
A Guide to SQL, Eighth Edition Chapter Two Database Design Fundamentals.
Fundamentals, Design, and Implementation, 9/e. Database Processing: Fundamentals, Design and Implementation, 9/e by David M. KroenkeChapter 4/2 Copyright.
Avoiding Database Anomalies
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
Chapter 4 The Relational Model and Normalization.
Concepts of Database Management Sixth Edition Chapter 5 Database Design 1: Normalization.
Concepts of Database Management, Fifth Edition
A Normalisation Example Mark Kelly McKinnon Secondary College Vceit.com Based on work by Robert Timmer-Arends.
1 A Guide to MySQL 2 Database Design Fundamentals.
Database Normalization Lynne Weldon July 17, 2000.
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.
Normalization Transparencies
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.
1 A Guide to MySQL 2 Database Design Fundamentals.
Chapter 5 – Database Management Systems
Lecture 5 Normalization. Objectives The purpose of normalization. How normalization can be used when designing a relational database. The potential problems.
Chapter 10 Normalization Pearson Education © 2009.
ITN Table Normalization1 ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (III) Normalization.
Database Design – Lecture 8
Component 4/Unit 6d Topic IV: Design a simple relational database using data modeling and normalization Description and Information Gathering Data Model.
Chapter 16: Using Relational Databases Programming Logic and Design, Third Edition Comprehensive.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
A337 - Reed Smith1 Structure What is a database? –Table of information Rows are referred to as records Columns are referred to as fields Record identifier.
Competitive (Business) Intelligence Systems The Road to Denormalization (starring Charlie Sheen & other Random Celebrities)
Normalization Example. Database Systems, 8 th Edition 2 Database Tables and Normalization Normalization –Process for evaluating and correcting table structures.
Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: Normalization.
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.
IST Database Normalization Todd Bacastow IST 210.
Microsoft Access 2010 Chapter 11 Database Design.
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.
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.
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.
SLIDE 1IS 257 – Fall 2006 Normalization Normalization theory is based on the observation that relations with certain properties are more effective.
1 Database Management Systems. Learning Objectives Describe the limitations of traditional application approaches to managing data Analyze the advantages.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 4: PART C LOGICAL.
Normalizing Database Designs. 2 Objectives In this chapter, students will learn: –What normalization is and what role it plays in the database design.
A Guide to SQL, Eighth Edition
Chapter 5: Logical Database Design and the Relational Model
Chapter 6 Application Controls EECS
System Analysis and Design
Normalization A337.
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
國立臺北科技大學 課程:資料庫系統 2015 fall Chapter 14 Normalization.
Chapter 14 Normalization Pearson Education © 2009.
Presentation transcript:

資料庫正規化 Database Normalization 取材自 AIS, 6 th edition By Gelinas et al.

2 Database Normalization Rules for database normalization based on set theory—failure to normalize results in anomalies/errors that otherwise might occur when adding, changing, or deleting data stored in the database –There are 6 normal forms, but the first 3 are generally considered sufficient –To function properly, a database should obtain the 3 rd normal form –Normal forms are inclusive, which means that each higher normal form includes all lower normal forms. –That is, a table in 3NF is in 1NF and in 2NF

3 Unnormalized Table/Relation Table contains repeating groups –Sales order line items repeat

4 Functional Dependence and Primary Keys An attribute (a column in a table) is functionally dependent on a second attribute (or a collection of other attributes), if a value for the first attribute determines a single value for the second attribute at any time. –If functional dependence exists, one would say that “the first attribute determines the second attribute.” A primary key contains a value that uniquely identifies a specific row in a table –A candidate attribute (a column or collection of columns) in a table is that table’s primary key if: 1. All attributes in the table are functionally dependent on the candidate attribute. 2. No collection of other columns in the table, taken together, has the first property.

5 Table/Relation in First Normal Form A table is in first normal form (1NF) if it doesn’t contain repeating groups. Rows are now key dependent, uniquely identified by a primary key The primary key for the table is a combination of SO_Number and Item_Number. A primary key formed by the combination of two or more columns is called a composite primary key.

6 Problems with first normal form (1NF) Includes the following functional dependencies: 1.Item_Number functionally determines Item_Name. Therefore, item names, such as “26 in. Bicycle,” are repeated several times. This data redundancy should be eliminated. 2.Cust_Code functionally determines Cust_Name. 3.The combination of SO_Number and Item_Number together functionally determine Item_Name, Qty_Ordered, Cust_Code, and Cust_Name. These functional dependencies cause several problems called update anomalies

7 Update Anomalies 1.Update. Updating an item name requires updating multiple records. Each row in which any item, such as the 26, in Bicycle, appears must be changed if the description is updated. 2.Inconsistent data. An item can have several different names in different rows of the table. 3.Additions. Adding a new inventory item to the database is impossible because a sales order number is required before an item can be inventoried. This is an impossible requirement for a business, which wants information about inventory in its database before accepting sales orders. 4.Deletions. Deleting an inventory item from the database (by deleting its row) could cause the table to lose sales order information. Because we have an attribute, Item_Name that is dependent on a portion of the primary key, Item_Number, not on the entire key. We have a problem called a partial dependency. Second normal form eliminates partial dependencies

8 Two steps to get from 1NF to 2NF 1.Create a new table for each subset of the table that is partially dependent on a part of the composite primary key –One table for SO_Number and another for Item_Number –We now have two new tables, one with SO_Number as its primary key (a SALES_ORDERS table) and another with Item_Number as its primary key (an INVENTORY_ITEMS table). 2.Place each of the non-key attributes that are dependent on a part of the composite primary key into the table that now has a primary key that is the field on which the non-key attribute is partially dependent. –For example, the Item_Name field is partially dependent on the Item_Number field portion of the composite primary key, so it would be moved into the new INVENTORY_ITEMS table. –This transformation yields the three tables shown in the next slide

9 Second Normal Form To obtain second normal form, partial dependencies must be eliminated by creating new tables

10 Third Normal Form To obtain the 3 rd normal form, transitive dependencies must be eliminated –A transitive dependency exists when a non-key field depends on another non-key field which in turn depends on the key (C depends on B which depends on A) –E.g., Customer name depends on customer code which depends on sales order number –A table is in third normal form if it is in second normal form and transitive dependencies are eliminated

11 Transitive Dependencies Some customer names—are repeated several times. This transitive dependency causes update anomalies: 1.Update. Changing any customer name could require multiple changes. The user would have to change each row in which any customer appears. Changing Wheelaway’s name would require changing three rows in the SALES_ORDERS table. 2.Inconsistent data. Nothing in this design prevents users from entering several different names for a single customer. 3.Additions. A new customer can’t be added unless the customer already has a sales order. Internal control dictates that an authorized customer should exist before a sales order can be created for that customer. 4.Deletions. If a user deletes a sales order, the name of a customer might be erased from the database.

12 Third Normal Form Customer information moved to customer table