Exercise 1 Back to the Book-Publisher Database 1.
-
Upload
suzanna-chapman -
Category
Documents
-
view
217 -
download
0
Transcript of Exercise 1 Back to the Book-Publisher Database 1.
![Page 1: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/1.jpg)
Exercise 1
Back to the
Book-Publisher
Database
1
![Page 2: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/2.jpg)
Recall the Scenario
2
![Page 3: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/3.jpg)
Book-Publisher DB
3
What remains is the “Contracts” and their details
![Page 4: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/4.jpg)
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 ???
![Page 5: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/5.jpg)
Book-Publisher DB
5
This means a contract has only one line
![Page 6: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/6.jpg)
Book-Publisher DB
6
Not in the ER standards
![Page 7: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/7.jpg)
Book-Publisher DB
7
![Page 8: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/8.jpg)
Exercise 2
Design Hotel database
8
![Page 9: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/9.jpg)
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
![Page 10: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/10.jpg)
10
Hotel
NameHQ Add. Manager
RatingTel.
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?
![Page 11: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/11.jpg)
11
Hotel
NameHQ Add. Manager
RatingTel.
Branch
ID
Add.
Tel.
Capacity
Type
Type
Num Beds
Capacity
Has TV
Has Balcony
Ver. 2
Observations:•Lets add relationships
RoomNum
![Page 12: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/12.jpg)
12
Hotel
NameHQ Add. Manager
RatingTel.
Branch
ID
Add.
Tel.
Capacity
Type
Type
Num Beds
Capacity
Has TV
Has 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.
![Page 13: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/13.jpg)
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
![Page 14: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/14.jpg)
14
Hotel
NameHQ Add. Manager
RatingTel.
Branch
ID
Add.
Tel.
Capacity
Type
Type
Num Beds
Capacity
Has TV
Has Balcony
Ver. 4
RoomNum
has
Of type
contains
Guest
IDAdd.
Tel.
Name
Money Paid
Length of stayStart date
End date
Observations:•“Stay” attributes should not be part of “Guest”
![Page 15: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/15.jpg)
15
Hotel
NameHQ Add. Manager
RatingTel.
Branch
ID
Add.
Tel.
Capacity
Type
Type
Num Beds
Capacity
Has TV
Has Balcony
Ver. 5
RoomNum
has
Of type
contains
Guest
IDAdd.
Tel.
Name
Money Paid
Length of stayStart date
End dateStays inObservations:
•Still not quite right..•“Stays-in” 1-M or M-M??(Guest should be able to stay in diff. rooms)
![Page 16: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/16.jpg)
16
Hotel
NameHQ Add. Manager
RatingTel.
Branch
ID
Add.
Tel.
Capacity
Type
Type
Num Beds
Capacity
Has TV
Has Balcony
Ver. 6
RoomNum
has
Of type
contains
Guest
IDAdd.
Tel.
Name
Money Paid
Length of stayStart date
End dateStays inObservations:
•Not done yet…•In this model, a guest cannot stay in the same room over diff visits!!!
![Page 17: Exercise 1 Back to the Book-Publisher Database 1.](https://reader035.fdocuments.us/reader035/viewer/2022070412/5697bf7c1a28abf838c83e90/html5/thumbnails/17.jpg)
17
Hotel
NameHQ Add. Manager
RatingTel.
Branch
ID
Add.
Tel.
Capacity
Type
Type
Num Beds
Capacity
Has TV
Has Balcony
Ver. 7
RoomNum
has
Of type
contains
Guest
IDAdd.
Tel.
Name
Money Paid
Length of stayStart date
End dateStays inObservations:
•Start_date part of key•Length of stay derived attribute