ER Model Slides
ER Model Slides
Students Courses
Instructors
ER Model
Entity Has attributes that describe
it
name address
id
ER Model
Entity set:
Is the set of entities that share the
same properties
Instructors
Courses
Y. Saygın H. Yenigün
CS306 MATH204
Instructors
Students
ER Model
Relationships:
Relate two or more entities (such as Ali is
enrolled in CS306)
ER Model
Relationships:
Relate two or more entities (such as Mert is enrolled in
CS306)
Relationship sets:
Collection of all relationship sets with the same properties
(all student enrollments)
ER Model
sid student
name
sid student
Course
name
cid
sid student
name
ER Model
Each entity set has attributes
Each attribute has a domain (domain is the set of
permitted values)
Each entity set has a key
Keys are denoted by underlining the attribute name in
the ER diagram
sid student
name
ER Model
cname
loan
ER Model
We may have relationships among the entities that belong to
the same entity set (Unary Relationships)
each entity has a role in such a relationship
students
helps
ER Model
We may have relationships among the entities that belong to
the same entity set (Unary Relationships)
each entity has a role in such a relationship
tutor tutee
helps
ER Model
Reports_to
ER Model
supervisor
Reports_to
ER Model
supervisor subordinate
Reports_to
ER Model
Ternary relationship sets
customer branch
loan
ER Model
Ternary relationship sets
loan
Mapping cardinalities
One-to-One relationship (ex: manages relationship between
employees and departments)
Employees Departments
1-to-1
Mapping cardinalities
One-to-Many: If an employee can manage multiple departments
Many-to-One: If Multiple employees can manage a department
(but not vice versa)
Many-to-Many: If An employee can managemultiple
departments and a department can be managed by multiple
employees.
If an employee can
manage multiple
departments but a
department has only
one manager
What type of
relationship is that?
If an employee can
manage multiple
departments but a
department has only
one manager
What type of
relationship is that?
What type of
relationship is
that?
since
name dname
ssn lot did budget
Works_In
since
Participation Constraints
Participation constraints are denoted with a thick line (for example
each department must participate in the manages relationship,
therefore this is denoted with a thick line in the relationship)
since
name dname
ssn lot did budget
Works_In
since
Participation Constraints
If every employee MUST work in a department, then there is a
participation constraint on employee entity set
since
name dname
ssn lot did budget
Works_In
since
Participation Constraints
Plus, if every department MUST have employee(s) working in that
department, then there is a participation constraint on department
entity set
since
name dname
ssn lot did budget
Works_In
since
name
ssn lot
hourly_wages hours_worked
contractid
Hourly_Emps Contract_Emps
name
ssn lot
hourly_wages hours_worked
ISA
contractid
Hourly_Emps Contract_Emps
name
ssn lot
Employees
hourly_wages hours_worked
ISA
contractid
Hourly_Emps Contract_Emps
name
cost pname age
ssn lot
name
cost pname age
ssn lot
Aggregation Employees
Used when we
have to model a Monitors until
relationship
involving (entitity
since
sets and) a started_on
dname
relationship set. pid pbudget did budget
Aggregation allows
Projects Sponsors Departments
us to treat a
relationship set as
an entity set for Aggregation vs. ternary relationship:
purposes of Monitors is a distinct relationship,
participation in with a descriptive attribute.
(other)
relationships. Also, can say that each sponsorship
is monitored by at most one employee.
Conceptual Design Using the ER
Model
Design choices:
Should a concept be modeled as an entity or an
attribute?
Should a concept be modeled as an entity or a
relationship?
Identifying relationships: Binary or ternary? Aggregation?
Constraints in the ER Model:
A lot of data semantics can (and should) be captured.
But some constraints cannot be captured in ER diagrams.
Entity vs. Attribute
Purchaser
Beneficiary
policyid cost
Summary of Conceptual Design