Professional Documents
Culture Documents
Designing E/R Diagrams
Designing E/R Diagrams
Designing E/R Diagrams
2005
Designing E/R
Diagrams
Relationship X Y
Is-insured Type
Entity type X is a subtype of type Y
Weak
Wedding Entity Type T1 T2
Type T1 and T2 are overlapping; an entity can
belong to both T1 and T2; default is disjoint
occurred Identifying
Relationship
phone# Multi-valued Attribute
Semester Course
name grade
semesterid title Cou#
took-not-a-set: -2.5
Other Errors: -1.5 (or 3-4 if major)
gre ssn
salary Student
name
(0,1) Grad
(1,*)
employs
(0,*) gpa
assoc
(0,75) (0.*)
took title
Department (0,*) Cou#
(0,*)
Semester Course
name grade (0,*)
semesterid
offered
(1,1)
took-not-a-set: -1.5
Section not weak: -2
Section
Other Errors: -0.5--1 if minor
-2—3 if major Time-offered classroom
Sal
name Month ssn
(0,*) birthd name
name from
to
(0,*)
(0,*)
Team (25,*) contr Player
city
Home Visit
(0,*) (0,*)
Contract set viol –3, (0,*)
pos
Other: -2 play
played-in.
(1,1)
pos
(18,*)
score
Game Date
Game#
(0,*) (0,*)
Wedding Is-insured Company
location
name
amount
to from
1
Christoph F. Eick: Designing E/R Diagrams
Priorities when Choosing
Between Valid E/R Diagrams
1. Express all constraints (you can express!)
2. Use and do not change terminology and
class structure of the application domain
3. Keep it simple (avoid defining entity types
that do not serve any purpose)
4. Avoid redundancy (but derived attributes
are okay)!
1
Christoph F. Eick: Designing E/R Diagrams
A Quite Bad E/R Diagrams
gpa Name
department
(0,*) (0,*)
works-
Person for
Company
gender
wife husband
(0,*)
ssn (0,*) (0,*)
salary takes
(0,*)
is-married-
to
Section S#
time
Course C#
1
Christoph F. Eick: Designing E/R Diagrams
Example: Too many Entity Types /
Don’t use Foreign Keys
Example: Persons as well as animals can be insured
P#
Name
(0,*) (0,*)
is-
Person insured Company
name
ssn (0,*)
Boss-ssn
1
Christoph F. Eick: Designing E/R Diagrams
Other Issues in E/R Design
1. No relationships of relationships --- solution: create an entity type
that represent instances of the relationship (or use aggregation as
discussed in the textbook)
2. value or entity type --- solution: choose entity type if it helps
expressing constraints; otherwise, use value-type.
1
Christoph F. Eick: Designing E/R Diagrams
University E/R Design Problem
Design a “good” entity-relationship diagram that describes the following objects in an
university application: students, instructors, professors, and courses. Students are
subdivided into graduate and undergraduate students. Students take a course in a
particular semester and receive a grade for their performance. Sometimes students
take the same course again in a different semester. There are no limits on how many
courses a student can take, and on how many students completed a particular course.
Each graduate student has exactly one advisor, who must be a professor, whereas each
professor is allowed to be the advisor of at most 20 students. Courses have a unique
course number and a course title. Students and professors have a name and a unique
ssn; students additionally have a gpa; moreover, graduate students have a GRE-score,
and undergraduate students have a single or multiple majors. Professors can be
students and take courses, but graduate students cannot be undergraduate students.
Indicate the cardinalities for each relationship type; assign roles (role names) to each
relationship if there are ambiguities! Use sub-types, if helpful to express constraints!
1
Christoph F. Eick: Designing E/R Diagrams
gre advises
Grad (0,1) (0,20) Professor ssn
name
major
Ugrad Student
(0,*) Person
grade took
gpa
(0,*)
(0,*)
Semester Course
title Cou#
semesterid
Enrolls-not-a-set: -4
Student must be ugrad or grad: -1
Other Errors: -2 (or –3 if quite major)
room-type
A:=guaranteed; B:=has_transaction; C:=for_hotel; D:=consists_of;
E:=for_category; F=avail-rooms; G=total-rooms; modified on Feb. 3, 2004
name
ssn lot
Aggregation Employees
Aggregation allows us
Projects Sponsors Departments
to treat a relationship
set as an entity set
for purposes of Aggregation vs. ternary relationship:
participation in Monitors is a distinct relationship,
(other) relationships.
with a descriptive attribute.
Also, can say that each sponsorship
is monitored by at most one employee.
2
Christoph F. Eick: Designing E/R Diagrams
NFL E/R Design ---
Ungraded Homework --- due: Th., Jan. 27,2005
2
Christoph F. Eick: Designing E/R Diagrams