You are on page 1of 13

Introduction to Normalization of Database Tables Introduction to Normalization of Database Tables Introduction to Normalization of Database Tables Introduction to Normalization of Database

Tables Normalization of Database Tables ISM 602 Dr. Hamid Nemati

Functional Dependency . A Functional Dependency Is A Relationship Between Or Among Attributes Such That The Values Of One Attribute Depend On, Or Are Determined By, The Values Of The Other Attribute(s). . Partial Dependency: Is A Relationship Between Attributes Such That The Values Of One Attribute Is Dependent On, Or Determined By, The Values Of Another Attribute Which Is Part Of The Composite Key. . Partial Dependencies Are Not Good Due To duplication Of Data And Update Anomalies; Transitive Dependencies . Is A Relationship Between Attributes Such That The Values Of One Attribute Is Dependent On, Or Determined By, The Values Of Another Attribute Which Is Not A Part Of The Key. . Exist when a nonkey attribute value is functionally dependent upon another nonkey value in the record. For example: l EMPLOYEE_ID --> JOB_CATEGORY l JOB_CATEGORY --> HOURLY_RATE . An employee data table that includes the hourly pay rate would require searching every employee record to properly update an hourly rate for a particular job category.

then we can uniquely determine his/her Name l SID S_Name So Now what is Normalization? . If we know Student-ID (SID). Goals Of Normalization: u Eliminate Redundancies Caused By: l Fields Repeated Within A File l Fields Not Directly Describing The Key Entity l Fields Derived From Other Fields . then we know the Book Title and the author(s) l ISBN Book Title l ISBN Author(s) . Avoid Anomalies In Updating (Adding. If we know the VIN. GOLDEN RULE OF NORMALIZATION: Enter The Minimum Data Necessary. If we know an ISBN. then we know who is the Auto owner l VIN Auto_Owner .Introduction to Normalization of Database Tables Introduction to Normalization of Database Tables Introduction to Normalization of Database Tables Normalization of Database Tables l Objectives 4 The idea of Dependencies of Attributes 4 Normalization and Database Design 4 Understand concepts of normalization (Higher-Level Normal Forms) 4 Learn how to normalize tables 4 Understand normalization and database design issues 4 Denomalization Examples of Functional Dependencies: . With Minimum Risks To Data Integrity. . Avoiding Duplicate Entry Of Information. . Editing.

Deleting) u Represent Accurately The Items Being Modeled u Simplify Maintenance And Retrieval Of Info .

Introduction to Normalization of Database Tables Normalization Benefits l Facilitates data integration. . It reduces data redundancies and helps eliminate the data anomalies. Normalization is a process for assigning attributes to entities. Corollary 2: A relational table should not have attributes involved in a transitive dependency relationship with the primary key. . The attribute values in a relational table should be functionally dependent (FD) on the primary key value. . A relationship is functionally dependent when one attribute value implies or determines the attribute value for the other attribute. . Normalization works through a series of stages called normal forms: u First normal form (1NF) u Second normal form (2NF) u Third normal form (3NF) . l Reduces data redundancy.Introduction to Normalization of Database Tables Introduction to Normalization of Database Tables Database Tables and Normalization . l EM_SS_NUM --> EM_NAME l Corollaries . The highest level of normalization is not always desirable. . Corollary 1: No repeating groups allowed in relational tables. Introduction to Normalization of Database Tables Basic Rule for Normalization .

. Employees assigned to the project. all the customer information could be lost when the order record is deleted l Solution: . Name. l Employee --Employee number. if the order is canceled. The hourly billing rate is dependent on the employee s position. . l Example: . l Deletion anomalies. u The table displays data redundancies. Reduces the chances of data anomalies occurring. Create two tables--one table contains order information and . Building project --Project number. Introduction to Normalization of Database Tables Database Tables and Normalization l Problems with the Table 5. Name. The company charges its clients by billing the hours spent on each project. l Compliments data modeling.1 . The data redundancies yield the following anomalies: l Update anomalies. Introduction to Normalization of Database Tables Deletion Anomaly . u The table entries invite data inconsistencies. but it contains nulls. l Addition anomalies. Job classification . Occurs when the removal of a record results in a loss of important information about an entity.Provides a robust architecture for retrieving and maintaining data. Introduction to Normalization of Database Tables Database Tables and Normalization l The Need for Normalization u Case of a Construction Company . All the information about a customer is contained in an order file. The project number is intended to be a primary key.

.the other table contains customer information.

Occurs when there does not appear to be any reasonable place to assign attribute values to records in the database. Where do you place information on new Evaluator s? Do you create a dummy Lead. l Solution: u Create a new table with a primary key that contains the relevant or functional dependent attributes.3) Database Table 5. l Solution: u Put the employees telephone number in one location--as an attribute in the employee table. . Repeating groups can be eliminated by adding the appropriate entry in at least the primary key column(s). l Example: u Adding new attributes or entire records when they are not needed. Introduction to Normalization of Database Tables Database Tables and Normalization l Conversion to First Normal Form u A relational table must not contain repeating groups. Occurs when a change of a single attribute in one record requires changes in multiple records l Example: u A staff person changes their telephone number and every potential customer that person ever worked with has to have the corrected number inserted. Probably have overlooked a critical entity. (See Database Table 5. Introduction to Normalization of Database Tables Insertion Anomaly .Introduction to Normalization of Database Tables Introduction to Normalization of Database Tables Update Anomaly .2 The Evergreen Data .

l Writing the dependent attributes after each new key. PROJ_NAME) l All attributes are dependent on the primary key. . the database can be tabular format in which: converted into the 2NF format by l All the key attributes are defined. HOURS) . The arrows above the entity indicate that the entity s attributes are dependent on the combination of PROJ_NUM and EMP_NUM. The arrows below the dependency diagram indicate less desirable dependencies based on only a part of the primary key --partial dependencies. EMP_NAME. and then writing the original key on the last line and l There are no repeating groups in the table. l Writing each key component on a separate line.Introduction to Normalization of Database Tables Database Tables and Normalization l Dependency Diagram .1 A Dependency Diagram: First Normal Form Introduction to Normalization of Database Tables Database Tables and Normalization Introduction to Normalization of Database Tables Database Tables and Normalization l 1NF Definition l Conversion to Second Normal Form u The term first normal form (1NF) describes the u Starting with the 1NF format. JOB_CLASS. PROJECT (PROJ_NUM. Figure 5. EMPLOYEE (EMP_NUM. EMP_NUM. CHG_HOUR) ASSIGN (PROJ_NUM.

u See figure 5. . Note: It is still possible for a table in 2NF to exhibit transitive dependency. EMP_LNAME. that is. JOB_CHG_HOUR) Figure 5. PROJ_NAME) EMPLOYEE (EMP_NUM. EMP_FNAME. Database Tables and Normalization l 3NF Definition u A table is in 3NF if: l It is in 2NF and l It contains no transitive dependencies. that is.2 page 290. JOB_DESCRIPTION.7 The Initial E-R Diagram for a Contracting Company Introduction to Normalization of Database Tables Introduction to Normalization of Database Tables Introduction to . no attribute is dependent on only a portion of the primary key. Introduction to Normalization of Database Tables Normalization and Database Design l Two Initial Entities: PROJECT (PROJ_NUM. one or more attributes may be functionally dependent on nonkey attributes. EMP_INITIAL.Introduction to Normalization of Database Tables Introduction to Normalization of Database Tables Introduction to Normalization of Database Tables Database Tables and Normalization l 2NF Definition u A table is in 2NF if: l It is in 1NF and l It includes no partial dependencies.

EMP_NAME. PROJECT (PROJ_NUM. Some employees are not assigned to a project and perform duties not specifically related to a project. JOB_CLASS) JOB (JOB_CLASS. . PROJ_NAME) ASSIGN (PROJ_NUM. Create a separate table with attributes in a transitive functional dependence relationship. Each employee has a (single) primary job classification. l An employee may be assigned to several different projects. EMP_INITIAL. HOURS) EMPLOYEE (EMP_NUM. Database Design and Normalization Example: (Construction Company) u Summary of Operations: l The company manages many projects. l Each project requires the services of many employees. Normalization and Database Design . JOB_CHG_HOUR) . . CHG_HOUR) Normalization and Database Design .Normalization of Database Tables Database Tables and Normalization l Conversion to Third Normal Form . PROJ_NAME) EMPLOYEE (EMP_NUM. l Many employees can have the same job classification. Three Entities After Transitive Dependency Removed PROJECT (PROJ_NUM. JOB_CODE) JOB (JOB_CODE. EMP_LNAME. EMP_FNAME. This job classification determines the hourly billing rate. EMP_NUM. Some employees are part of a labor pool. JOB_DESCRIPTION. to be shared by all project teams.

l Manages relationship is created between EMPLOYEE and PROJECT. JOB_CHG_HOUR) ASSIGN (ASSIGN_NUM. EMP_NUM. EMP_FNAME. ASSIGN_DATE. EMP_LNAME.8 The Modified E-R Diagram for a Contacting Company Introduction to Normalization of Database Tables Normalization and Database Design l Creation of the Composite Entity ASSIGN Figure 5. PROJ_NUM. JOB_DESCRIPTION. EMP_NUM) EMPLOYEE (EMP_NUM. JOB_CODE) JOB (JOB_CODE. ASSIGN_HOURS) Introduction to Normalization of Database Tables Normalization and Database Design Figure 5. EMP_INITIAL.Introduction to Normalization of Database Tables Normalization and Database Design Figure 5. EMP_HIREDATE. PROJECT (PROJ_NUM.9 The Final (Implementable) E-R Diagram for the Contracting Company Introduction to Normalization of Database Tables Normalization and Database Design l Attribute ASSIGN_HOUR is assigned to the composite entity ASSIGN.10 The Relational Schema for the Contracting Company Introduction to Normalization of Database Tables Summary A Journey of Normalization First Normal Form (1NF) . PROJ_NAME.8 The Modified E-R Diagram for a Contacting Company Introduction to Normalization of Database Tables Normalization and Database Design Figure 5.

. The conflict between design efficiency. Normalization purity is often difficult to sustain in the modern database environment. .Remove Repeating Groups Remove Partial Functional Dependency Remove Transitive Functional Dependency Second Normal Form (2NF) Third Normal Form (3NF) Higher order Normal Forms Remove All Remaining Functional Dependency Introduction to Normalization of Database Tables Denormalization . information requirements. and processing speed are often resolved through compromises that include denormalization. . Normalization is only one of many database design goals. reducing system speed. Normalized (decomposed) tables require additional processing.