Presentation is loading. Please wait.

Presentation is loading. Please wait.

WJEC Applied ICT Databases – Attributes & Entities Normalisation It is important in Database Design to make sure that the correct attributes are grouped.

Similar presentations


Presentation on theme: "WJEC Applied ICT Databases – Attributes & Entities Normalisation It is important in Database Design to make sure that the correct attributes are grouped."— Presentation transcript:

1 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation It is important in Database Design to make sure that the correct attributes are grouped into the correct tables. Normalisation is a process that allows us to do this. This reduces the duplication of data and helps stop inconsistencies. Normalisation is done in three phases – 1NF, 2NF and 3NF. These are as follows 1)1NF – Atomic Data Test 2)2NF – Partial key dependence test 3)3NF – Non-key dependence test

2 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Consider this table: There are multiple entries for some of the attributes. How much space should we leave for these. These attributes are said to be “repeating groups” or non- atomic data. Lets remove them to another table. Order Number Customer ID Delivery Address Email Address Order Date Item Code DescOrder Quantity Unit Price 012367BLF1Fred Bloggs 1 High Street, Any town Fredloggs @NT.co.u k 01/05/091234Ring Binder 31.50 8967Divider40.50 3456Stapler12.99 034231SMJ2Joe Smith 7, The Lane, Anytown JoeSmith @NT.co.u k 03/05/099684Scissors21.99 3456Stapler42.99

3 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Table 1 in 1NF Order Number Customer ID Delivery Address Email Address Order Date 012367BLF1Fred Bloggs 1 High Street, Any town Fredloggs @NT.co.u k 01/05/09 034231SMJ2Joe Smith 7, The Lane, Anytown JoeSmith @NT.co.u k 03/05/09

4 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Table 2 in 1NF Order number and Item code make a composite key. OrderNumberItem CodeDescOrder Quantity Unit Price 012367 1234Ring Binder31.50 012367 8967Divider40.50 012367 3456Stapler12.99 034231 9684Scissors21.99 034231 3456Stapler42.99

5 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Which of these tables are NOT in first normal form?

6 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Moving to 2NF The item details are only dependant on the item code which is part of the key and not the OrderNumber as well. This also means we only store details of the items when we order them. To make it 2NF all the attributes must be dependant on the full key. We create another table for the items. OrderNumberItem CodeDescOrder Quantity Unit Price 012367 1234Ring Binder31.50 012367 8967Divider40.50 012367 3456Stapler12.99 034231 9684Scissors21.99 034231 3456Stapler42.99

7 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Table 1 in 2NF Order Number Customer ID Delivery Address Email Address Order Date 012367BLF1Fred Bloggs 1 High Street, Any town Fredloggs @NT.co.u k 01/05/09 034231SMJ2Joe Smith 7, The Lane, Anytown JoeSmith @NT.co.u k 03/05/09

8 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Table 2 in 2NF OrderNumberItem CodeOrder Quantity 012367 12343 012367 89674 012367 34561 034231 96842 034231 34564

9 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Table 3 in 2NF Item CodeDescUnit Price 1234Ring Binder1.50 8967Divider0.50 3456Stapler2.99 9684Scissors1.99 3456Stapler2.99

10 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Moving to 3NF If we go back to first table - Order Number Customer ID Delivery Address Email Address Order Date 012367BLF1Fred Bloggs 1 High Street, Any town Fredloggs @NT.co.u k 01/05/09 034231SMJ2Joe Smith 7, The Lane, Anytown JoeSmith @NT.co.u k 03/05/09 The primary key here is the OrderNumber. However the Delivery Address and Email Address is dependant on the Customer ID. So this table is not in Third Normal Form (3NF) because it fails the non- key dependance test. So we must create a new table for the customer information.

11 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Let us have a look at our 4 tables now in 3NF. Table : OnlineOrder Order Number Customer ID Order Date 012367BLF101/05/09 034231SMJ203/05/09 Table: Customer Customer ID Delivery Address Email Address BLF1Fred Bloggs 1 High Street, Any town Fredloggs@N T.co.uk SMJ2Joe Smith 7, The Lane, Anytown JoeSmith@N T.co.uk

12 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Let us have a look at our 4 tables now in 3NF. Table: ItemOrder OrderNumberItem CodeOrder Quantity 012367 12343 012367 89674 012367 34561 034231 96842 034231 34564 Table: Item Item CodeDescUnit Price 1234Ring Binder1.50 8967Divider0.50 3456Stapler2.99 9684Scissors1.99 3456Stapler2.99

13 ICT@ WJEC Applied ICT Databases – Attributes & Entities Normalisation Tasks 1)Can you write the new tables in Database notation? 2)Can you create an Entity Relationship Diagram for the new Customer Order System? 3)Have a go at the scenarios below. Can you put the following flat files into 3NF. CAR (Make, Model, Name of part, Price, Supplier name, supplier telephone number, Supplier Address)  RACES (Race name, venue, start point, end point, miles, runner name, time to finish, club name, club address, club telephone number) Runners only belong to one club.


Download ppt "WJEC Applied ICT Databases – Attributes & Entities Normalisation It is important in Database Design to make sure that the correct attributes are grouped."

Similar presentations


Ads by Google