Download presentation
Presentation is loading. Please wait.
Published bySuzanna Chapman Modified over 9 years ago
1
Exercise 1 Back to the Book-Publisher Database 1
2
Recall the Scenario 2
3
Book-Publisher DB 3 What remains is the “Contracts” and their details
4
Book-Publisher DB 4 We modeled the contract between “Authors” & “Publishers” We made the contract “date” part of the key now an author can have multiple contracts with the same publisher over time. What about contract lines ???
5
Book-Publisher DB 5 This means a contract has only one line
6
Book-Publisher DB 6 Not in the ER standards
7
Book-Publisher DB 7
8
Exercise 2 Design Hotel database 8
9
Example: Hotel Database A Hotel has many branches Hotel name, logo, address of HQ, Tel., manager, star rating Branch Id, address, Tel., Total capacity Each branch has many rooms with different types and numbers. A room type defines Room size, Number of beds Has TV or not, Has Balcony or not These attributes of the room depend on its type Guests can stay in a hotel for a period of time Guests have unique ID, name, address, Tel. We need to capture, the length of the stay, start date, end date, money paid 9
10
10 Hotel Name HQ Add.Manager Rating Tel. Branch ID Add. Tel. Capacity Room Num Type Num Beds Capacity Has TV Has Balcony Ver. 1 Observations: Room type is modeled as attribute (causes redundancy) Room number, is it numeric like 1001? If so, how come to be unique across branches?
11
11 Hotel Name HQ Add.ManagerRatingTel.BranchIDAdd.Tel.CapacityType Num BedsCapacityHas TVHas Balcony Ver. 2 Observations: Lets add relationships RoomNum
12
12 Hotel Name HQ Add.ManagerRatingTel.BranchIDAdd.Tel.CapacityType Num BedsCapacityHas TVHas Balcony Ver. 3 RoomNum has Of type contains Common mistake: Do not add “Branch ID” as an attribute to “Room” entity set. It is already captured by the weak relationship “contains”. Observation: Not all relationships of “Room” are “supporting” relationships. Only the one that completes my key.
13
Back to the Requirements A Hotel has many branches Hotel name, logo, address of HQ, Tel., manager, star rating Branch Id, address, Tel., Total capacity Each branch has many rooms with different types and numbers. A room type defines Room size, Number of beds Has TV or not, Has Balcony or not Guests can stay in a hotel for a period of time Guests have unique ID, name, address, Tel. We need to capture, the length of the stay, start date, end date, money paid 13
14
14 Hotel Name HQ Add.ManagerRatingTel.BranchIDAdd.Tel.CapacityType Num BedsCapacityHas TVHas Balcony Ver. 4 RoomNum has Of type contains Guest ID Add. Tel. Name Money Paid Length of stayStart date End date Observations: “Stay” attributes should not be part of “Guest”
15
15 Hotel Name HQ Add.ManagerRatingTel.BranchIDAdd.Tel.CapacityType Num BedsCapacityHas TVHas Balcony Ver. 5 RoomNum has Of type contains Guest ID Add. Tel. Name Money Paid Length of stay Start date End date Stays in Observations: Still not quite right.. “Stays-in” 1-M or M-M?? (Guest should be able to stay in diff. rooms)
16
16 Hotel Name HQ Add.ManagerRatingTel.BranchIDAdd.Tel.CapacityType Num BedsCapacityHas TVHas Balcony Ver. 6 RoomNum has Of type contains Guest ID Add. Tel. Name Money Paid Length of stay Start date End date Stays in Observations: Not done yet… In this model, a guest cannot stay in the same room over diff visits!!!
17
17 Hotel Name HQ Add.ManagerRatingTel.BranchIDAdd.Tel.CapacityType Num BedsCapacityHas TVHas Balcony Ver. 7 RoomNum has Of type contains Guest ID Add. Tel. Name Money Paid Length of stay Start date End date Stays in Observations: Start_date part of key Length of stay derived attribute
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.