MLLecture2 PDF
MLLecture2 PDF
MLLO 20180228
What is a Model?
❖ A model is an abstract representation of (a part of)
➢ Physical world
➢ Domain with a lot of details
➢ Complicated set of things
❖ Different models have
➢ Different degrees of abstraction
➢ Different degrees of expressive power (model power)
Database Some data
and need for
Application Design application
Modeling
Relational model OO model Networked model
Student University
A: E → P(V)
○ Note: the power set of a set S is the set of all subsets of S, including empty set.
○ E.g. S={a, b}, P(S) = { {}, {a}, {b}, {a, b}}
● For single-valued attributes, A(E) maps only to singleton sets in P(V)
● For multivalued attributes, A(E) maps to all of P(V) . That is, there is no
restriction in the mapping
Relationship
● Intuitively:
○ Relationship in daily experience
● ER model:
○ An attribute of one entity type refers to another entity type
○ In ER model, such reference should be relationship rather than attribute
● ER model design
○ Relationship are usually initially captured in the form of attributes.
○ As the design is refined, these attributes gets converted into relationships between entity types
Designing Relationship in ER Modeling
Student Department
A Dog B
Tom
Cat
Mary
Bird
John
Fish
Degree of Relationships Binary relationship,
degree=2
● The degree of a relationship Student enroll Department
type is the number of
participating entity types
● Relationship can be of any
ID Name Age ID Name
degree in theory
● Relationship of degree 2: binary.
Most common. ID Name
● Relationship of degree 3: ternary Ternary relationship
● In theory there is no limit to the Degree=3 Part
number of degree
Supplier supply Project
● In practice, binary or ternary are
most frequently used
ID Cname ceo ID Name
Role Name
● For each entity type participating in
Student enroll Department
a relationship type, a role name
signifies the role it plays in each
relationship instance.
ID Name Age ID Name
● Role names are not technically
necessary in relationship types
where all the participating entity Role name: Role name:
types are distinct. student department
○ Each participating entity type
name can be used as the role
name.
● Role names are indispensable in
recursive relationships.
super-
Recursive Relationship vise
Superviser Supervisee
● Structural Constraints
○ We refer to Cardinality Ratio and Participation Constraints together as Structural Constraints
Review and Think
→ Structure of what?
N Work 1 N Work 1
EMPLOYEE DEPT EMPLOYEE DEPT
for for
Start
date
e1 w1
e2 w2 p1
e3 w3
e4 w4 p2
e5 w5
e6 w6 p3
e7 w7
Relationship as Attribute We can also think of and implement
relationship as attribute
● If we do not plan to access the other
Start entity independently in the application
date
N Work 1 Working
EMPLOYEE DEPT EMPLOYEE
for DEPT
Start
date
Nam Nam Nam
ID e
Age ID e ID e
Age
Generalization d
U
U
U
Secretary Technician Engineer Subclass/subtype
U
U
U
Secretary Technician Engineer Subclass/subtype
Employee
d U
U
U
Project
EER example (3)
Total specialization
ID name
Disjoint specialization Disjoint specialization
Employee
d U d Hourly
U
U
U
U
U pay
Secretary Technician Engineer Manager Salary_ Hourly_
Employee Employee