Uploaded by Tanmay Patel

Class 2 - Normalizing a Relation - 101455495

advertisement
1. Based on the functional dependencies, here is the first normal form (1NF).
Pet (Pet#, PetName, AmountOwedm HandlerID#, HandlerName, WalkCode, WalkInfo,
HandlerWalkFee, WalkDate)
Pet,HandlerID -> Primary keys
2. First Normal Form (1NF) to Second Normal Form (2NF)
Pet (Pet#, PetName)
Pet -> Primary Key
HandlerWalk (HandlerID#, HandlerName, WalkCode#, WalkInfo, HanlderWalkFee, WalkDate,
AmountOwed, Pet)
HandlerID, WalkCode -> PrimaryKey
Pet -> Foreign Key
Second Normal Form (2NF) to Third Normal Form (3NF)
Pet (Pet#, PetName)
Pet -> Primary Key
Handler (HandlerID#, HandlerName)
HandlerID -> Primary Key
Walk (WalkCode#, WalkInfo, HandlerWalkFee, WalkDate, AmountOwed, Pet, HandlerID)
WalkCode -> Primary Key
Pet, HandlerID -> Foreign Key
3. The database design needs to include an Attribute for the date of the Pet's last walk. In
which Entity/Table would you place this Attribute, and why?
We do not need to add the Pet’s Last Walk as an Attribute. This is because it can be easily found
out using the WalkDate Attribute. We can write a query in the database that will reveal the
information without having the need to add it as a separate column.
For Example, in SQL the query would look like:
Select top 1 Pet.PetName, Walk.WalkDate
From Walk
LeftJoin
Pet on Pet.Pet = Walk.Pet
Where PetName = (Name of the Pet)
Order by Walk.WalkDate Desc
Yet if the need exists then the Last Walk Attribute can be added under the Pet Entity with a
code that will replace the date based on the latest date available for the pet’s walk from the
Walk Table. This will make it easy to record the data along with the pet’s name and can be filter
using a single table. This will only cause data redundancy that can be avoided by the solution
provided above.
Download