Pregunta

this is a homework which I already did, I just need either confirmation if it is done correctly or hints how to solve it. Thanks.
This is the question:

The relation Vaccine is intended to record information about infants and their vaccinations: when a particular infant had a particular vaccination; where the vaccination took place; who administered the vaccine. The following gives the relational heading:
Vaccine(VaccineCode, InfantId, Date, InfantName, InfantAddress, MedicalCentreCode,MedicalCentreName, MedicalCentreAddress,NurseId, NurseName)

Besides the functional dependencies with the primary key as their determinant, Vaccine has the following non-trivial functional dependencies:
FD1:InfantId -> InfantName
FD2:InfantId -> InfantAddress
FD3:MedicalCentreCode -> MedicalCentreName
FD4:MedicalCentreCode -> MedicalCentreAddress
FD5:NurseId -> NurseName

Give this relation ship first in 2NF and then in 3NF.

My solution:
2NF:
Infant(InfantID, InfantName,InfantAddress)
Rest(VaccineCode, InfandID, Date, MedicalCentreCode, MedicalCentreName, MedicalCentreAddress, NurseId, NurseName)

Now Infant is in 2NF and also in 3NF but Rest relation isn't in 3NF. 3NF for all those relation will look like this (according to me ofcourse):
VaccinationDetails(VaccineCode, InfantID, Date ,MedicalCentreCode NurseId)

Infant(InfantID, InfantName, InfantAddress)

MedicalCentre(MedicalCentreCode, MedicalCentreName, MedicalCentreAddress)

Nurse(NurseId, NurseName)

Are my solutions 2NF and 3NF?

¿Fue útil?

Solución

2NF requires that the relation a) be in 1NF, and b) have no partial key dependencies.

Projecting Infant (InfantID, InfantName,InfantAddress) from the original relation is correct. InfantName and InfantAddress are functionally dependent on InfantID; InfantID is part of the key {VaccineCode, InfantId, Date}.

Now Infant is in 2NF and also in 3NF but Rest relation isn't in 3NF.

That's right. 3NF requires a) the relation be in 2NF, and b) have no transitive dependencies. There's one transitive dependency from {VaccineCode, InfantId, Date} to MedicalCentreCode to {MedicalCentreName, MedicalCentreAddress}. So removing that transitive dependency by projection gives you

  • Infants {InfantID, InfantName,InfantAddress}
  • MedicalCentres {MedicalCentreCode, MedicalCentreName, MedicalCentreAddress}
  • Vaccinations {VaccineCode, InfantID, Date, MedicalCentreCode, NurseId, NurseName}

And there's another transitive dependency involving NurseID and NurseName. Projecting that one gives you

  • Infants {InfantID, InfantName,InfantAddress}
  • MedicalCentres {MedicalCentreCode, MedicalCentreName, MedicalCentreAddress}
  • Nurses {NurseID, NurseName}
  • Vaccinations {VaccineCode, InfantID, Date, MedicalCentreCode, NurseId}

Those four relations are all now in at least 3NF. (The first three are in 5NF.)

Going beyond your homework

But there's a small problem with this. As it stands now, you can enter the medical center code for "General Hospital", and the id number of a nurse who doesn't work there. You might think about how you'd express that dependency, and what the resulting relations might look like.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top