Professional Documents
Culture Documents
User Interface Design 16. Data Modelling
User Interface Design 16. Data Modelling
A B stayID, paymethod
stayID, paymethod
A B
3. UID16.1 E/R data model for a hotel
Rooms
4. Extra: Some index cards
Guest
Name: Entity-relationship data model
John Simpson
Address: 456 Orange … Class = entity class
Phone: table
23 558 … Guest
Passport:
1:m
One-to-many relationship
Stay 9802 Stay
Pay by: visa
Date Room m:m
E/R model: Many-to-many relationship
23/8 12 Lists forbidden
24/8 12 on a card Room
24/8 11
A class contains:
Room Put the date objects = entities
roomID: here? records
12
bedCount: 2
Type: Double
Price 1: 80
Price 2: 60
5. UID16.2 Attributes and keys
Fields = attributes
Guests name, address,
Guest
phone, passport
Key field:
Unique identification
stayID, paymethod,
Stay
Stays
date
stayID, paymethod
Stay
Stays
date
personCount,
state (booked | occ | repair) RoomState
RoomStates
enumeration type
name, address,
Guest
phone, passport
stayID, paymethod
Stay
date
personCount,
state (booked | occ | repair) RoomState
name,
address1,
address2, Guest
address3, name, price
phone,
passport
Service Service
Stay
stayID, Received Type Remove this class?
paymethod,
state (booked | in | date, quantity Add to ServiceReceived:
out | canceled) Room serviceType (fullBreakfast |
State continental | . . . )
date, personCount,
state (booked | occupied | repair)
roomID,
bedCount, type Room
price1, price2
9. UID16.4 Relational data model
Guest
guestID name address1 . . .
Primary
32 John Si... 456 Orange Gr Guest
key
33 Lise Ha... Dysseg... 57
- artificial
38 Yun Chen Kirch... 6
Route
attributes?
attributes?
From
City Leg attributes?
To
Next
1:1 relation
14. UID16.8 Example: Text processor
Style ??
Section margin, paperSize,
headers, columns
D1
projID, name,
sDeptID, name, (deptID) SubDept (headqtID, deptID, sDeptID)
16. UID16.9 Hierarchies (cont.)
D1
Dept
Dept Project
deptID name belongsTo
has
D1 HeadQt
be
l
on
D1.2 Personnel D1
D1.3 Development D1
D1.1.1 Sydney D1.1
D1.1.2 Melbourne D1.1
D1.3.1 Hardware D1.3
D1.3.2 Software D1.3
17. UID16.10 Network model: road map
Road ??
Section ??
Point ??
Private Dealer
1:1 variant:
A B Each A has a B (don’t know about zero)
Each B has zero or one A
m:m variant
A B Each A has one or more Bs
Each B has zero or more As
21. UID16.12A Notational variations (cont.)
UML notation
1:1 1: Each A has one or more Bs
A B
Each B has one A
date, state
m m Diamond notation
Stay Room
m:m: Make diamond a connection class
#persons
A B C
Two feet facing the same way
make one long foot
A C
A B C
Two feet facing opposite
ways make many-to-many
A C
Stay Room
Resolve many-
to-many with a
connection box
Room
Stay Room
state
23. UID16.12B UML and broken connectors
0:
Activity Building 1:1 Contract
Building 0:1
1:1 0: wish 0: 1:1
period
0:
1: 0:
1:1 1:1 0: 0:1
Class 0: 1: Request Room 1:
Line Request Room
activity 0:1 1:1 hour hour 1:1
1:1 0: 1:1
1: 1:1 0: 1:1
0:
1:1
0: Room 0: Room
Class
0: wish property
1:1 1:1
0:
1:
1:1
Class 0: Property
Property
hours wish 0: 1:1
1:
1:1 0:1
1:1
Time 0:1 0: User 1:1 Authoriz
User
table 0: 1:1 authoriz 0: type
24. UID16.12B Room allocation system in E/R notation
Room Room
Class
wish property
Class Property
Property
hours wish
Employee CourseTaken
27. UID16.14B Second normal form
Doesn’t
depend
Second normal form: on empID
First normal form +
Non-key fields must depend on entire key. CoursesTaken
empID courseID courseName year
100 1 Windows 1996
Cure: 100 2 Word 1996
Move fields depending on a partial key to a 100 3 Access 1997
separate table. 101 2 Word 1996
102 2 Word 2000
102 3 Access 2001
CoursesTaken
empID courseID year
100 1 1996 Courses
100 2 1996 courseID courseName
100 3 1997 1 Windows
101 2 1996 2 Word
102 2 2000 3 Access
102 3 2001
CourseTaken Course
28. UID16.14C Third normal form & final model
Depends
only
Third normal form: on deptID
Second normal form +
Non-key fields must be independent. Employees
empID name deptID deptName
100 Thomson 5 Sales
Cure: 101 Smith 7 Accounting
Move interdependent fields to a separate table. 102 Bunting 5 Sales
Employees Departments
empID name deptID deptID deptName
100 Thomson 5 5 Sales Omit deptID and
101 Smith 7 7 Accounting use deptName
102 Bunting 5 as the key?
Employee Department
name
deptName
CourseTaken Course
year
courseName
29. UID16.14D Hotel system normalization
Depend
only
on type
Rooms
roomID type bedCount price1 price2 Hard to change
011 Double, bath 2 80 70 prices for 400
012 Single, toilet 1 60
rooms
013 Double, bath 2 80 70
014 Single, toilet 1 60
015 Double, bath 2 80 70
016 Single, bath 1 70
... Easy to change
prices for 8
room types