Sie sind auf Seite 1von 8

We will look at 4 types of Normalization problems.

Normalization Exercise 1: Already in 3NF

HEALTH HISTORY REPORT

PET ID PET NAME PET TYPE PET AGE OWNER Total 2012
246 ROVER DOG 12 SAM COOK $500.00
298 SPOT DOG 2 TERRY KIM $423.00
341 MORRIS CAT 4 SAM COOK $397.60
519 TWEEDY BIRD 2 TERRY KIM $602.50
602 ROVER DOG 12 JASMIN LI $332.55

3NF: PET [ PetId, PetName, PetType, PetAge, Owner, Total_2012 ]

Normalization Exercise 2: A Single Multi-Valued Dependancy

DETAILED HEALTH HISTORY REPORT

PET ID PET NAME PET TYPE PET AGE OWNER VISIT DATE PROCEDURE
246 ROVER DOG 12 SAM COOK JAN 13/2013 01 - RABIES VACCINATION
MAR 27/2013 10 - EXAMINE and TREAT WOUND
APR 21/2013 05 - HEART WORM TEST

298 SPOT DOG 2 TERRY KIM JAN 21/2013 08 - TETANUS VACCINATION


MAR 10/2013 05 - HEART WORM TEST

341 MORRIS CAT 4 SAM COOK JAN 23/2012 01 - RABIES VACCINATION


JAN 13/2013 01 - RABIES VACCINATION

519 TWEEDY BIRD 2 TERRY KIM APR 21/2013 20 - ANNUAL CHECK UP


APR 30/2013 12 - EYE WASH

This is One Pet has Many visits.


The Multi-valued dependancy consists of (VisitDate, Proc#, Procedure)
UNF: PET [ PetId, PetName, PetType, PetAge, Owner, ( Visitdate, ProcedureNo,
ProcedureName ) ]

1NF: PET [ PetId, PetName, PetType, PetAge, Owner, Visitdate, ProcedureNo,


ProcedureName ]

2NF: PET [ PetId, PetName, PetType, PetAge, Owner ]


PET_VISIT [ PetId, Visitdate, ProcedureNo, ProcedureName ]

3NF: PET [PetId, PetName, PetType, PetAge, OwnerId(FK) ]


PET_VISIT [ PetId, Visitdate, ProcedureNo(FK) ]
PROCEDURE [ProcedureNo, ProcedureName ]
Normalization Exercise 3: Two Independent Multi-Valued Dependencies

Here we are concerned about relations that have two or more multi-valued dependencies. Each
dependency is separate. It is not the case that one of the multi-valued dependencies is inside the
other multi-valued dependency. The example we will use is a Route and Driver List for a
particular day.

A Route has many Drivers and many Stops, but the Drivers are not related to the
Stops. The Drivers are related to the Route.
The stops are also related to the Route.

Route and Driver List


Mins to
Route RouteName Driv# Driver Name Stop NextStop
196A York Univ. 1149 Led Foote Downsview 5
1251 Slo Snail Sheppard 12
3202 Joe Horne Keele 10
Sentinel 7
Finch 4
York Univ
_______
Total time 41

196B York Express 1040 Joe Axident Downsview 5


1251 Slo Snail Sheppard 14
Keele 11
York Univ
_______
Total time 30

Notice that the time between stops depends on the route. The 196A takes 12 minutes to get
from Sheppard to Keele, but the 196B takes 14 minutes. This is because more riders get on
to the Express bus and an extra 2 minutes is needed for the time it takes for these extra
riders to get on.

UNF: [ Route# , RouteName, (Driver#, DriverName), (Stop, MinsToNextStop)]

1NF : Eliminate multi-valued dependencies.

First the DRIVER multi-valued dependency.


[ Route#, RouteName] I.
[ Route#,Driver#, DriverName] II.

Next, the STOP multi-valued dependency.


(Route#, Stop, MinsToNextStop] III.

So the tables in 1NF are:

[ Route#, RouteName] I.
[ Route#,Driver#, DriverName] II.
[ Route#, Stop, MinsToNextStop] III.

2NF: Eliminate Partial Dependencies

(Route#,Driver#, DriverName) II.

(Driver#, DriverName) II.A


(Route#,Driver#) II.B

So the tables in 2NF are:

(Route#, RouteName) I.
(Driver#, DriverName) II.A
(Route#,Driver#) II.B
(Route#, Stop, MinsToNextStop) III.
3NF: Eliminate Transitive Dependencies

It is likely that each Stop is identified by a unique Stop Number so:

I. ROUTE [Route#, RouteName ]


II.A) DRIVER [Driver#, DriverName ]
II.B) ROUTE-DRIVER [Route#,Driver# ]
III.A) DRIVING_TIME [Route#, StopId, MinsToNextStop]
III.B) STOP( StopId , StopName ]

The basic idea is to treat each independent multi-valued dependency separately.


Normalization Exercise 4: A Multi-Valued Dependencies Embedded inside
another Multi-Valued Dependency

Here we see one PetId can have Many VisitDates and each VisitDate can have Many
Procedures,

DETAILED HEALTH HISTORY REPORT

PET ID PET NAME PET TYPE PET AGE OWNER VISIT DATE PROCEDURE
246 ROVER DOG 12 SAM COOK JAN 13/2013 01 - RABIES VACCINATION
10 - EXAMINE and TREAT WOUND
APR 21/2013 05 - HEART WORM TEST

298 SPOT DOG 2 TERRY KIM JAN 21/2013 08 - TETANUS VACCINATION


MAR 10/2013 05 - HEART WORM TEST
09 – BLOOD TEST
10 - EXAMINE and TREAT WOUND

341 MORRIS CAT 4 SAM COOK JAN 23/2012 01 - RABIES VACCINATION


JAN 13/2013 01 - RABIES VACCINATION

519 TWEEDY BIRD 2 TERRY KIM APR 21/2013 20 - ANNUAL CHECK UP


APR 30/2013 12 - EYE WASH
UNF: PET [ PetId, PetName, PetType, PetAge, Owner, ( Visitdate, ( ProcedureNo,
ProcedureName ) ) ]

1NF: PET [ PetId, PetName, PetType, PetAge, Owner, Visitdate, ProcedureNo,


ProcedureName ]

rewriting:

PET [ PetId, Visitdate, ProcedureNo,PetName, PetType, PetAge, Owner, ProcedureName ]

2NF: There are 7 possible tables when we resolve a 3-part key

3 @ 1-part PK’s

[ PetId,
[ Visitdate,
[ ProcedureNo

3 @ 2-part PK’s

[ PetId, Visitdate
[ PetId, ProcedureNo
[ Visitdate, ProcedureNo

1 @ 3-part PK

[ PetId, Visitdate, ProcedureNo

We examine each non-key attribute and place it on the table whose PK


determines it’s value.

A) [ PetId, PetName, PetType, PetAge, Owner ]


B) [ Visitdate,
C) [ ProcedureNo , Procedure ]
D) [ PetId, Visitdate
E) [ PetId, ProcedureNo
F) [ Visitdate, ProcedureNo
G) [ PetId, Visitdate, ProcedureNo

Now we decide if we need the tables which have no non-key attributes.

A) [ PetId, PetName, PetType, PetAge, Owner ]


C) [ ProcedureNo , Procedure ]
G) [ PetId, Visitdate, ProcedureNo ]

3NF: Now we identify and eliminate transitive dependancies and mark Foreign Keys

PET [PetId, PetName, PetType, PetAge, OwnerId(FK) ]


PET_VISIT [ PetId(FK), Visitdate, ProcedureNo(FK) ]
PROCEDURE [ProcedureNo, ProcedureName ]
OWNER [ OwnerId, Owner ]

Das könnte Ihnen auch gefallen