Vous êtes sur la page 1sur 5

Normalisation Exercises

1. Check the following database design language against the rules for Normalisation and ensure that each entity is in third normal form. The practice has many patients, each patient has only one practice. Over time a patient will have many appointments with a doctor who is identified by the Med taff!". #ractice #atient $#ractice!", #racticeName% $N& No, #'irstName, # urname, #(ddress, #ractice!", (ppointmentNo, (ppointmentTime, (ppointment"ate, Med taff!"% ') #ractice!"*#ractice +pdate cascade "elete restrict

Answer
Table #ractice, has no multi,value attributes and so is in first normal form, it has a single primary key so it is in second normal form, it has a single non key attribute and so it is in third normal form. Table #atient, we know that a patient may have many appointments, this means that for (ppointmentNo, (ppointment time, (ppointment date, Med taff!" we need to store more than one value, these are multi value attributes. Table patient is split as follows. (ll the appointment attributes are removed the following entities are in first normal form. #ractice #atient $#ractice!", #racticeName% $N& No, #'irstName, # urname, #(ddress, #ractice!"% ') #ractice!"*#ractice +pdate cascade "elete restrict

#at(ppoint

$N& No, (ppointmentNo, (ppointmentTime, (ppointment"ate, Med taff!"% ') N& No*#atient +pdate cascade "elete restrict

Table patient is in second normal form as it has a single primary key. Table appointment has a compound key and so must be checked against the rules for second normal form. -e check each of the non key fields to ensure they are fully

dependent on the -&O./ of the primary key. -e can see that we only need (ppointmentNo, to identify (ppointmentTime, (ppointment"ate, Med taff!" and these can be removed to form a new entity. (ll the entities are now in second normal form. #ractice #atient $#ractice!", #racticeName% $N& No, #'irstName, #surname, #address, #ractice!"% ') #ractice!"*#ractice +pdate cascade "elete restrict

#at(ppoint

$N& No, (ppointmentNo% ') N& No*#atient +pdate cascade "elete restrict

(ppointment $(ppointmentNo, (ppointmentTime, (ppointment"ate, Med taff!"% ') (ppointmentNo*#at(ppoint +pdate cascade "elete restrict

(s already discussed table practice is in third normal form. !n table patient all the non key attributes are independent of each other and therefore patient is in third normal form. Table #at(ppoint consists of key only attributes, we must check that there is no dependency between key attributes. 0iven a patient N& No we could not uni1uely identify an appointment number, however given an (ppointmentNo we can uni1uely identify the patient as each appointment is only for one patient, as a result N& No does not need to be part of the #rimary )ey for this entity and can be converted to a non key field. #at(ppoint is now in third normal form. #at(ppoint $(ppointmentNo, N& No% ') N& No*#atient +pdate cascade "elete restrict

'inally table (ppointment, all the non key fields are fully independent of each other therefore (ppointment is in third normal form. The entities identified are now as follows. 'inally check that there are no entities that can be combined. Notice that through normali2ation we now have two entities with the same primary key highlighted in red, these are effectively the same entity and can

be combined into a single entity which caters for all the re1uirements of both separate entities. #ractice #atient $#ractice!", #racticeName% $N& No, #'irstName, #surname, #address, #ractice!"% ') #ractice!"*#ractice +pdate cascade "elete restrict

#at(ppoint

$(ppointmentNo, N& No% ') N& No*#atient +pdate cascade "elete restrict

(ppointment $(ppointmentNo, (ppointmentTime, (ppointment"ate, Med taff!"% ') (ppointmentNo*#at(ppoint +pdate cascade "elete restrict

The final cumulative design is as follows. #ractice #atient $#ractice!", #racticeName% $N& No, #'irstName, #surname, #address, #ractice!"% ') #ractice!"*#ractice +pdate cascade "elete restrict

(ppointment $(ppointmentNo, (ppointmentTime, (ppointment"ate, Med taff!", N& No% ') N& No*#atient +pdate cascade "elete restrict

3. Check the following database design language against the rules for Normalisation and ensure that each entity is in third normal form. /ach member of the medical staff belongs to only one practice, a practice has many members of medical staff. Medical taff $Med taff!", M 'irstName, M urname, M (ddress, M Type, #ractice!", #racticeName% /ach attribute in Medical taff will only hold a single value therefore Medical taff is in first normal form. Medical taff has a single primary key therefore Medical taff is in second normal form. Medical taff has a single primary key so there are no dependencies between key fields, it has a number if non key attributes and we must check for dependencies between non key fields. M 'irstName, M urname, M (ddress and M Type are all independent of each other however #racticeName is dependent on #ractice!", #ractice!" is the foreign key in table medical staff. The following entities are created. #ractice $#ractice!", #racticeName% urname, M (ddress,

Medical taff $Med taff!", M 'irstName, M M Type, #ractice!"% ') #ractice!"*#ractice +pdate cascade "elete restrict

4. Check the following database design language against the rules for Normalisation and ensure that each entity is in third normal form. /ach type of clinic is run once a week, one member of medical staff is in charge of each clinic. /ach member of medical staff may run many clinics. -eeklyClinic $Clinic!", "ate, ClinicType, Med taff!", M 'irstName, M urname% 'or each weekly clinic there is only one ClinicType and one member of medical staff for whom the following data is stored Med taff!", M 'irstName and M urname. Therefore Clinic is in 'irst normal form. Clinic has a compound key to identify the staff for a clinic we need both elements of the key. 5ut we only need the clinic!" to identify the ClinicType these can be removed to form a new clinic entity. 5oth entities are now in second normal form.

Clinic

$Clinic!", ClinicType%

-eeklyClinic $Clinic!", "ate, ClinicType, Med taff!", M 'irstName, M urname% ') Clinic!"*Clinic +pdate cascade "elete restrict

Clinic has a single primary key and a single non key attribute so it is in thrid normal form. -eeklyClinic needs to be checked against the rule for third normal form. The two key fields are independent of each other so must both remain as part of the key. Clinic Type is independent of the other non key attributes. &owever M 'irstName, and M urname are both dependent on Med taff!" and will form a new entity. Med taff!" will become a foreign key in -eeklyClinic. -e now have three entities in third normal form. Clinic $Clinic!", ClinicType% urname%

Medical taff $Med taff!", M 'irstName, M

-eeklyClinic $Clinic!", "ate, ClinicType, Med taff!"% ') Clinic!"*Clinic +pdate cascade "elete restrict Med taff!"*Medical taff +pdate cascade "elete restrict

')

Vous aimerez peut-être aussi