Normalization is a method for organizing data elements in a database into tables. Normalization Avoids
Before Normalization 1. Begin with a list of all of the fields that must appear in the database. Think of this as one big table. 2. Do not include computed fields 3. One place to begin getting this information is from a printed document used by the system. 4. Additional attributes besides those for the entities described on the document can be added to the database. Before Normalization – Example See Sales Order from below: --------------------------------------------------------------------------------------------------- Sales Order XYZ Enterprises 406 River Drive Manhattan, KS 66502 Customer Number: 2251 Sales Order Number: 2000325 Customer Name: ABC & Sons Inc. Sales Order Date: 10/08/2010 Customer Address: 138 Points Place Clerk Number: 62530 Manhattan, KS 66502 Clerk Name: Dio Mindra ___________________________________________________________________________ Item Ordered Description Quantity Unit Price Total Price ---------------------------------------------------------------------------------------------------- 905 60 Gig PC Hard-drives 40 $ 60.00 $ 2,400.00 822 External Speakers 20 20.00 400.00 304 1 Gig RAM PC AV-31X 100 50.00 5,000.00 ---------------------------------------------------------------------------------------------------- Order Total $ 7,800.00 ___________________________________________________________________________ Fields in the original data table will be as follows: SalesOrderNo, Date, CustomerNo, CustomerName, CustomerAdd, ClerkNo, ClerkName, ItemNo, Description, Qty, UnitPrice Note: Think of this as the baseline – one large table Normalization: First Normal Form
The new table is as follows: SalesOrderNo, ItemNo, Description, Qty, UnitPrice The repeating fields will be removed from the original data table, leaving the following. SalesOrderNo, Date, CustomerNo, CustomerName, CustomerAdd, ClerkNo, ClerkName These two tables are a database in first normal form What if we did not Normalize the Database to First Normal Form? Repetition of Data – SO Header data repeated for every line in sales order. Normalization: Second Normal Form
The new table will contain the following fields: ItemNo, Description All of these fields except the primary key will be removed from the original table. The primary key will be left in the original table to allow linking of data: SalesOrderNo, ItemNo, Qty, UnitPrice Never treat price as dependent on item. Price may be different for different sales orders (discounts, special customers, etc.) Along with the unchanged table below, these tables make up a database in second normal form: SalesOrderNo, Date, CustomerNo, CustomerName, CustomerAdd, ClerkNo, ClerkName What if we did not Normalize the Database to Second Normal Form?
The new tables would be: CustomerNo, CustomerName, CustomerAdd ClerkNo, ClerkName All of these fields except the primary key will be removed from the original table. The primary key will be left in the original table to allow linking of data as follows: SalesOrderNo, Date, CustomerNo, ClerkNo Together with the unchanged tables below, these tables make up the database in third normal form. ItemNo, Description SalesOrderNo, ItemNo, Qty, UnitPrice What if we did not Normalize the Database to Third Normal Form?
|
Database Table Normalization
Tags
Database Technology
Social: