Upload
shannon-johns
View
221
Download
0
Tags:
Embed Size (px)
Citation preview
1
Normalisation
A2 ICT
2
The Data ProblemEquipment Service RecordItem Ref……10…………………… Location…Garage………………………Item Name……Buggy………………… Location Ext……1234……………Item Type……non-critical…………………….Purchase date…23/05/99…………………
Service ref Date of Work Tasks Required Tasks Performed Serviced By Date of Next Service Cost £
1 23/05/01 Grease wheels As required P.K. Jones 23/05/02 5.00
2 23/05/02 New bearings and general service
As required Kennedys 23/05/03 10.00
3 01/04/03 Brake test Brakes fixed P.K. Jones 23/05/03 20.00
Total Cost to date £35.00
3
Why do we normalise?
• Data duplication – wasting space
• Redundant data
• Same data held in several records/tables
• Data inconsistency – difficult to maintain
4
Step 1Equipment Service RecordItem Ref……10…………………… Location…Garage………………………Item Name……Buggy………………… Location Ext……1234……………Item Type……non-critical…………………….Purchase date…23/05/99…………………
Service ref Date of Work Tasks Required Tasks Performed Serviced By Date of Next Service Cost £
1 23/05/01 Grease wheels As required P.K. Jones 23/05/02 5.00
2 23/05/02 New bearings and general service
As required Kennedys 23/05/03 10.00
3 01/04/03 Brake test Brakes fixed P.K. Jones 23/05/03 20.00
Total Cost to date £35.00
a) This part of the form relates to the Item
b) This part of the form relates to the Service Records
We can see that one Item can have many
Service Records
5
Step 1
Item Ref
Item
Service Ref
Item Ref (FK)
Service Record
We have identified the first two entities from the record cards.
Add the Primary Keys and use a Foreign Key to link the two entities to identify the relationship.
6
Step 1
Item RefItem NameItem TypeLocationLocation ExtnPurchase Date
tbl_Item
Service RefTask RequiredTask PerformedDate of WorkDate next serviceItem Ref (FK)Serviced byCost
tbl_Service
We have identified the first two entities from the record cards.
Add the Primary Keys and use a Foreign Key to link the two entities to identify the relationship.
7
tbl_Itemtbl_Item (Item_Ref, Item_Name, Item_Type, Location, Location_Extn, Purchase_Date)
Item_Ref Item_Name Item_Type Location Location_Extn
Purchase_Date
10 Buggy Non-critical Garage 1234 23/05/99
21 Paintball Gun
Critical Shed 789 12/09/00
23 Deep Fryer Catering HQ 2222 03/07/00
35 Quad Bike Semi Critical
Garage 1234 09/08/99
54 Pool Car Vehicle Garage 1234 24/02/97
8
tbl_Itemtbl_Item (Item_Ref, Item_Name, Item_Type, Location, Location_Extn, Purchase_Date)
Item_Ref Item_Name Item_Type Location Location_Extn
Purchase_Date
10 Buggy Non-critical Garage 1234 23/05/99
21 Paintball Gun
Critical Shed 789 12/09/00
23 Deep Fryer Catering HQ 2222 03/07/00
35 Quad Bike Semi Critical
Garage 1234 09/08/99
54 Pool Car Vehicle Garage 1234 24/02/97
Repeats
9
Step 2
Item RefItem NameItem TypeLocation Ref (FK)Purchase Date
tbl_Item
We have created a new entity for the Location to remove the repeated fields from tbl_Item
A new field Location Ref has been created to link the two tables.
Location RefLocationLocation Extn
tbl_Location
10
tbl_Itemtbl_Item (Item_Ref, Item_Name, Item_Type, Location Ref, Purchase_Date)
Item_Ref Item_Name Item_Type Location_Ref Purchase_Date
10 Buggy Non-critical 1 23/05/99
21 Paintball Gun Critical 2 12/09/00
23 Deep Fryer Catering 3 03/07/00
35 Quad Bike Semi Critical 1 09/08/99
54 Pool Car Vehicle 1 24/02/97
11
tbl_Locationtbl_Location (Location_Ref, Location, Location_Extn)
Location_Ref Location Location_Exn
1 Garage 1234
2 Shed 789
3 HQ 2222
12
First Normal Form
• The data in our three tables can now be described as having been normalised to First Normal Form
• This means that all fields on every table are related to the Primary Key on that table
13
First Normal Form
Item RefItem NameItem TypeLocation Ref (FK)Purchase Date
tbl_Item
Location RefLocationLocation Extn
tbl_Location
tbl_Service
Service RefTask RequiredTask PerformedDate of WorkDate next serviceItem Ref (FK)Serviced byCost
14
Second Normal Form
• This data in also in Second Normal Form
• This means that all fields are related to the whole Primary Key – this stage of normalisation relates to entities with compound keys (where the primary key is made up of more than one field)
• This stage doesn’t affect our tables, all of which have a single primary key
15
Second Normal Form
Item RefItem NameItem TypeLocation Ref (FK)Purchase Date
tbl_Item
Location RefLocationLocation Extn
tbl_Location
tbl_Service
Service RefTask RequiredTask PerformedDate of WorkDate next serviceItem Ref (FK)Serviced byCost
16
Third Normal Form
• Third Normal Form requires the fields to be only related to the entity/table to which they belong
• If we look at our entities we can see that this is not the case
• The field Serviced_by relates to an external entity which should have attributes of its own
17
tbl_Servicetbl_Service (Service_Ref, Date_of_Work, Item_Ref, Task_Required, Task_Done, Serviced_by, Date_next_service, Cost) 1 23/05/01
10 Grease wheels As req’d P. K. Jones 23/05/02 5.00
2 23/05/02
10 New bearings and general service
As req’d Kennedy’s 23/05/03 10.00
3 01/04/03
10 Brake test Brakes fixed P. K. Jones 23/05/04 20.00
4 12/02/01
21 Routine check As req’d JD Gasses 12/02/01 5.00
5 10/02/01
21 Routine check Re gassed PK Jones 10/05/03 6.00
6 10/04/03
21 Barrel block unblock PK Jones 10/05/03 7.00
7 03/09/00
23 Change fuse As req’d Kennedys 03/10/00 5.00
8 03/10/00
23 Change fat Change fat & scrub JD Gasses 03/01/01 10.00
9 09/02/00
35 Routine service Plugs & oil Yale Motors
02/10/00 55.00
10 30/09/00
35 Routine service Plugs & oil & fan belt Yale Motors
30/3/01 60.00
11 26/02/97
54 Re-start New fuses Kennedys 24/02/98 20.00
12 22/02/98
54 Service As required Yale Motors
22/02/99 30.00
13 22/02/99
54 Major Service As required new tyres also
Yale Motors
22/02/00 300.00
This can cause several problems with
the data being held
18
tbl_Servicetbl_Service (Service_Ref, Date_of_Work, Item_Ref, Task_Required, Task_Done, Serviced_by, Date_next_service, Cost) 1 23/05/01
10 Grease wheels As req’d P. K. Jones 23/05/02 5.00
2 23/05/02
10 New bearings and general service
As req’d Kennedy’s 23/05/03 10.00
3 01/04/03
10 Brake test Brakes fixed P. K. Jones 23/05/04 20.00
4 12/02/01
21 Routine check As req’d JD Gasses 12/02/01 5.00
5 10/02/01
21 Routine check Re gassed PK Jones 10/05/03 6.00
6 10/04/03
21 Barrel block unblock PK Jones 10/05/03 7.00
7 03/09/00
23 Change fuse As req’d Kennedys 03/10/00 5.00
8 03/10/00
23 Change fat Change fat & scrub JD Gasses 03/01/01 10.00
9 09/02/00
35 Routine service Plugs & oil Yale Motors
02/10/00 55.00
10 30/09/00
35 Routine service Plugs & oil & fan belt Yale Motors
30/3/01 60.00
11 26/02/97
54 Re-start New fuses Kennedys 24/02/98 20.00
12 22/02/98
54 Service As required Yale Motors
22/02/99 30.00
13 22/02/99
54 Major Service As required new tyres also
Yale Motors
22/02/00 300.00
Repeated data
19
tbl_Servicetbl_Service (Service_Ref, Date_of_Work, Item_Ref, Task_Required, Task_Done, Serviced_by, Date_next_service, Cost) 1 23/05/01
10 Grease wheels As req’d P. K. Jones 23/05/02 5.00
2 23/05/02
10 New bearings and general service
As req’d Kennedy’s 23/05/03 10.00
3 01/04/03
10 Brake test Brakes fixed P. K. Jones 23/05/04 20.00
4 12/02/01
21 Routine check As req’d JD Gasses 12/02/01 5.00
5 10/02/01
21 Routine check Re gassed PK Jones 10/05/03 6.00
6 10/04/03
21 Barrel block unblock PK Jones 10/05/03 7.00
7 03/09/00
23 Change fuse As req’d Kennedys 03/10/00 5.00
8 03/10/00
23 Change fat Change fat & scrub JD Gasses 03/01/01 10.00
9 09/02/00
35 Routine service Plugs & oil Yale Motors
02/10/00 55.00
10 30/09/00
35 Routine service Plugs & oil & fan belt Yale Motors
30/3/01 60.00
11 26/02/97
54 Re-start New fuses Kennedys 24/02/98 20.00
12 22/02/98
54 Service As required Yale Motors
22/02/99 30.00
13 22/02/99
54 Major Service As required new tyres also
Yale Motors
22/02/00 300.00
Inconsistencies
20
Step 3
Item RefItem NameItem TypeLocation Ref (FK)Purchase Date
tbl_Item
We have created a new entity for the Servicer, tbl_Service
A new field Servicer_ID has been created to link the two tables. We can now add the other fields that we were given relating to this new entity
Location RefLocationLocation Extn
tbl_Location
tbl_Service
Service RefTask RequiredTask PerformedDate of WorkDate next serviceItem Ref (FK)Servicer_ID (FK)Cost
Servicer_IDServicer NameContactPhone NumberAddress
tbl_Servicer
21
tbl_Servicetbl_Service (Service_Ref, Date_of_Work, Item_Ref, Task_Required, Task_Done, Servicer_ID, Date_next_service, Cost)
1 23/05/01
10 Grease wheels As req’d 1 23/05/02 5.00
2 23/05/02
10 New bearings and general service
As req’d 2 23/05/03 10.00
3 01/04/03
10 Brake test Brakes fixed 1 23/05/04 20.00
4 12/02/01
21 Routine check As req’d 3 12/02/01 5.00
5 10/02/01
21 Routine check Re gassed 1 10/05/03 6.00
6 10/04/03
21 Barrel block unblock 1 10/05/03 7.00
7 03/09/00
23 Change fuse As req’d 2 03/10/00 5.00
8 03/10/00
23 Change fat Change fat & scrub 3 03/01/01 10.00
9 09/02/00
35 Routine service Plugs & oil 4 02/10/00 55.00
10 30/09/00
35 Routine service Plugs & oil & fan belt 4 30/3/01 60.00
11 26/02/97
54 Re-start New fuses 2 24/02/98 20.00
12 22/02/98
54 Service As required 4 22/02/99 30.00
13 22/02/99
54 Major Service As required new tyres also
4 22/02/00 300.00
22
tbl_Servicertbl_Servcier (Servicer_ID, Servicer_Name, Contact, Phone No, Address)
Servicer_ID Servicer_Name
Contact Phone Number
Address
1 P. K. Jones Robert Smith 88888888888 3, High Road, Mold, MO6 5DF
2 Kennedy’s Big Phil 123456789 Big Street, Wrexham LL34 2PQ
3 J D Gasses Gassy John 11111111111 33, Main Road, Chester, CH6 9LK
4 Yale Motors Mike Jones 54545454 Grove Park Road, Wrexham LL34 5BG
23
Third Normal Form
Item RefItem NameItem TypeLocation Ref (FK)Purchase Date
tbl_Item
Location RefLocationLocation Extn
tbl_Location
tbl_Service
Service RefTask RequiredTask PerformedDate of WorkDate next serviceItem Ref (FK)Servicer_ID (FK)Cost
Servicer_IDServicer NameContactPhone NumberAddress
tbl_Servicer
24
System improvements
Item RefItem Name
Location Ref (FK)Purchase DateType_Ref (FK)
tbl_Item
Location RefLocationLocation Extn
tbl_Location
tbl_Service
Service RefTask RequiredTask PerformedDate of WorkDate next serviceItem Ref (FK)Servicer_ID (FK)Cost
Servicer_IDServicer NameContactPhone NumberAddress
tbl_Servicer
Type_RefItem_TypeService_Interval
tbl_Type
25
tbl_Itemtbl_Item (Item_Ref, Item_Name, Type_Ref, Location Ref, Purchase_Date)
Item_Ref Item_Name Type_Ref Location_Ref Purchase_Date
10 Buggy N 1 23/05/99
21 Paintball Gun C 2 12/09/00
23 Deep Fryer K 3 03/07/00
35 Quad Bike S 1 09/08/99
54 Pool Car V 1 24/02/97
26
tbl_Typetbl_Type (Type_Ref, Item_Type, Service Interval)
Type_Ref Item_Type Service_Interval
N Non Critical 12
C Critical 3
K Catering 3
S Semi Critical 6
V Vehicle 12
27
How does this help?
• Can automatically calculate next service dates
• Can easily change service intervals if necessary
• Can add extra categories when required