05 — Practice solutions

← Questions

These are independently written explanations, not an official marking scheme.

05A

Dependencies include AppointmentID → PetID, Time; PetID → PetName, OwnerID; OwnerID → OwnerName. Owner details depend transitively on the appointment key through the pet and owner identifiers.

Owner(OwnerID PK, OwnerName)
Pet(PetID PK, PetName, OwnerID FK → Owner)
Appointment(AppointmentID PK, PetID FK → Pet, Time)

Owner 1:M Pet; Pet 1:M Appointment. Minimum participation on the “many” side depends on whether owners/pets may be recorded before pets/appointments exist; the supplied facts establish the maximum cardinalities.

05B

Customer(CustomerID PK, Name, Phone)
Bento(BentoID PK, Name, Price)
Orders(OrderID PK, CustomerID FK → Customer,
       BentoID FK → Bento, Quantity, OrderedAt, CollectionDate)

Customer 1:M Orders and Bento 1:M Orders. The proposed pair collides when one customer makes two orders for the same collection date. OrderID independently identifies each occurrence.

05C

Remove BentoID and Quantity from Orders. Add OrderLine(OrderID PK/FK → Orders, BentoID PK/FK → Bento, Quantity). Orders 1:M OrderLine and Bento 1:M OrderLine implement Orders M:N Bento. Quantity depends on the entire (OrderID, BentoID) key, because different bento types within an order can have different quantities.

05D

StageRelations / change
UNFOrder header includes OrderDate; the product group repeats.
1NFOrderItem(OrderID, ProductID, CustomerID, CustomerName, OrderDate, ProductName, Quantity); PK (OrderID, ProductID).
2NFOrders(OrderID PK, CustomerID, CustomerName, OrderDate); Product(ProductID PK, ProductName); OrderLine(OrderID PK/FK, ProductID PK/FK, Quantity).
3NFSplit Customer out: Customer(CustomerID PK, CustomerName) and Orders(OrderID PK, CustomerID FK, OrderDate); retain Product and OrderLine.

At 2NF, OrderDate and customer facts depend on OrderID alone, and ProductName on ProductID alone: partial dependencies on the composite key. At 3NF, remove OrderID → CustomerID → CustomerName. OrderDate describes the order and stays in Orders. Each OrderLine foreign key references the corresponding parent primary key.