Sie sind auf Seite 1von 19

Normalization of database tables

Normalization
 

It is the process of evaluating and correcting table structure to minimize data redundancies . It work through series of stages called normal form. The first three stage are describe as first normal from( 1NF), second normal form (2NF), third normal form (3NF). For business database design purpose 3 NF is highest normalization process. Higher the normal form the more relational join operation are required and also more resources are required by database system to respond to end user quires. Denormalization produce a lower normal form that is 3NF will be converted to a 2NF.

The normalization process


The objective is to create a table that have the following characteristics:


Each table represent a single subject. e.g. course table will contain only data that is directly pertains to course. Similarly student table contain only student data. No data item will be unnecessarily stored in more than one table. the reason for this requirement is to generate that the data are updated in only one place. All attributes in a table are dependent on the primary key.

First normal form


  

All of the key attribute are defined. There are no repeating groups. i.e. each row / column intersection contains one and only one value. An attributes are depends on the primary key. Step1. Eliminate the repeating groups:

 

Start by presenting the data in a tabular format, where each cells has a single value and there are no repeating groups. To eliminate the repeating groups, eliminate the nulls by making sure that each repeating groups attribute contain an appropriate data values.

Data present in this form now you have to create table for following data.
Project_no 15 Pr_name Evergreen Emp_no 103 101 105 16 Wave 114 116 104 25 Starlight 115 112 101 Emp_name Sumit Jitin Lalit Rahul Amit Abhinav Kamal Sonu Jitin Desg Analyst Programmer DBA Clerk Analyst Manager Engg. Designer Programmer Chg_hour $84 $45 $120 $12 $84 $96 $92 $52 $45 Hours 23.8 19.4 35.7 23 15 9 12 18 8

A table in first normal form


Project_no 15 15 15 16 16 16 25 25 25 Pr_name Evergreen Evergreen Evergreen Wave Wave Wave Starlight Starlight Starlight Emp_no 103 101 105 114 116 104 115 112 101 Emp_name Sumit Jitin Lalit Rahul Amit Abhinav Kamal Sonu Jitin Desg Analyst Programmer DBA Clerk Analyst Manager Engg. Designer Programmer Chg_hour $84 $45 $120 $12 $84 $96 $92 $52 $45 Hours 23.8 19.4 35.7 23 15 9 12 18 8

Step2. Identify the primary key




In this example project_num is not adequate primary key because the project_num does not uniquely identify all of the remaining attributes. E.g. Proj_num value 15 can identify any one of 3 employees. So to maintain a proper primary key that will uniquely identify any attribute value, the new key must be composed of combination of Project_num and Emp_num. E.g. Proj_num=15 and emp_no=103 the values are Sumit, Analyst, $84, 23.8

Step 3. Identify all dependencies.




The identification of Primary key in step 2 means that already identified following dependencies. Proj_num, Emp_num Pr_name, Emp_name, Desg, Chg_hour, Hours. Pr_name, Emp_name, Desg, Chg_hour, Hours are dependent on combination of Proj_num and emp_num.

Additional dependencies are : Proj_num Pr_name. if you know the Pr_name you can easily find out the Proj_num. emp_num emp_name, desg, chg_hour, hours. If you know the emp_no than you can also know emp_name, desg, chg_hours, hours. Desg chg_hour by knowing the chg_hour you can easily identify the desg.

Dependencies


Proj_num, Pr_name, emp_no, Emp_name, Desg, Chg_hour, Hours. ( Proj_num, emp_no both are primary key. When Proj_num + emp_no combine together it make composite primary key.)

Dependencies: when attributes depended on one or more primary key than it is known as dependencies. Proj_num, Emp_num Pr_name, Emp_name, Desg, Chg_hour, Hours.

Partial dependencies


In it attribute depends on any one part of primary key. Proj_num Pr_name. emp_num emp_name, desg, chg_hour, hours. ( Proj_num is primary key and emp_num is primary key.)

Transitive dependencies


When any non primary key attribute depend on another non primary key attribute it is known as transitive dependencies. Desg chg_hour ( both attribute are non primary key because primary key attribute are only Proj_num and Emp_num). Note: all table satisfy the 1NF requirement but the problem with 1NF structure is that it contain partial dependencies that is dependencies based on only a part of primary key.)

Second normal form


 

It is 1NF. It include no partial dependencies that is attribute depend on only a portion of primary key. The 1NF to 2NF conversion is simple starting with 1NF . Step1. write each key component on separate line. Proj_num (primary key) Emp_num(Primary key) Proj_num Emp_no ( composite Primary key). Each component will become the key in new table. Now the original table is divided into three new tables ( project, employee, assignment).

Step 2. Assign corresponding dependent attributes. Determine those attributes that are dependent on other attributes. In another words find the partial dependencies of 1NF and describe new tables on behalf of partial dependencies. Proj_num Pr_name. emp_num emp_name, desg, chg_hour, hours. The above partial dependencies i.e. from 1NF it create two tables i.e. Project & employee . but hours depend on two primary key attribute (Proj_num and Emp_no). i.e. number of hours spent on each project by each employee is dependent on both Proj_num and emp_num. so third table assignment also to be created.

Project ( Proj_num, Pr_name) - Proj_num is P.K (Project- Table). Employee( emp_no, emp_name, desg, chg_hour) emp_no is P.K (employee Table). Assignment ( Proj_num, Emp_num, Assign_hours) Proj_num , emp_num is P.K (Assignment - table).

Note: all table satisfy the 2NF requirement but the problem with 2NF structure is that it contain transitive dependencies means non primary key attribute depends on another non primary key attributes.) Desg chg_hour

Third normal form


 

It is 2NF. It contain no transitive dependencies. Desg chg_hour Step1. Identify each new determinant For every transitive dependencies write its determinant as Primary key for a new table. ( Determinant is any attribute whose value determine other value within a row.) e.g. if you have three transitive dependencies than you have three determinants. So determinant for above transitive dependencies is Desg

Step2. identify the dependent attributes. Identify the attributes that are dependent on each determinant identified in step 1 and identify the dependencies. Desg chg_hour name the table to reflects its contents i.e. Job

Step 3. Remove the dependent attribute from transitive dependencies. Eliminate all dependent attribute in the transitive relationship from each of the table that have such transitive relationship. E.g. chg_hour from employee table. Emp_num emp_name, desg, chg_hour ( Position in 2NF) Emp_num emp_name, desg ( 3NF) Desg remain in employee table to serve as foreign key. Now after conversion your report data change to four table.

Table create after 3NF


   

Project ( Proj_num , Pr_name). Employee ( emp_num, emp_name, desg) Job ( desg, chg_hour) Assignment (Proj_num, Emp_num, Assign_hour)

Das könnte Ihnen auch gefallen