Lecture 07 Erd PDF
Lecture 07 Erd PDF
Lecture 07 Erd PDF
Lecture 7
Outline
1. Context
– Design & Implementation Process
2. Goals of Conceptual Design
3. Entity-Relationship (ER) Model
4. One ER Diagrammatic Notation
5. Requirements Elicitation
6. Approaches to Conceptual Design
Comprehensive
• Entity types, relationships, and constraints
• Sanity check of data & functional requirements
• Reference for [unit/integration] testing/analysis
Concise/High-level
• Easy to understand technically
• Easy to communicate with non-technical users
• Facilitates focus on data (vs. storage/implementation details)
Algorithmically Transformable
• Improves application development efficiency, reduces errors
Attribute
• Property of an entity
• Most of what we store in the database
Relationship
• Association between sets of entities
• Possibly with attribute(s)
ER Diagrams
• Graphical depiction
of an ER model
• Many notations, this
class…
All cars have a year, age, make, model,
registration (unique), vehicle number
(vin; unique), some number of colors…
Specialization/Generalization
Entity Sets
Set of entities that have Make Year Model
the same attributes
Composite Attributes
Can be subdivided into Make Year Model
smaller subparts
State Number
Multivalued Attributes
Can take a [possibly Make Year Model
specified] number of
values.
Color CAR
All cars have a year,
make, model, Registration
registration, and some
number of colors. State Number
Key Attributes
The value uniquely Make Year Model
identifies each entity
make, model,
registration (unique), Registration
vehicle number (vin;
unique), some number State Number
of colors.
Potential Pitfall
• In relational schema, underlining multiple
attributes indicates that for all rows, the
combination is unique
Derived Attributes
Age
Exercise
Draw an ERD for the following description:
Answer
Name Number
Manager_
Start_Date
Exercise
Draw an ERD for the following description:
Answer
Name Number
Location PROJECT
Controlling_
Department
Exercise
Draw an ERD for the following description:
Answer
Salary
SSN Sex
Department Birthdate
EMPLOYEE
Supervisor Address
MI LName Hours
Exercise
Draw an ERD for the following description:
Answer
Sex
Employee
DEPENDENT DBirthdate
Relationship
DName
Relationships
Associates one or more sets of entities
– One = recursive (role is important)
STUDENT DEPT
CHAIR_F
Relationships
Associates one or more sets of entities
– One = recursive (role is important)
MAJOR_D
STUDENT DEPT
CHAIR_F
Relationships
Associates one or more sets of entities
– One = recursive (role is important)
MAJOR_D
STUDENT DEPT
MINOR_D
CHAIR_F
Relationships
Associates one or more sets of entities
– One = recursive (role is important)
MAJOR_D
STUDENT DEPT
MINOR_D
Tutor Tutee
TUTORS CHAIR_F
FACULTY
Cardinality Ratios
Constrains the number of entities that can
participate in each role of the relationship
MAJOR_D
STUDENT DEPT
MINOR_D
1
Tutor Tutee
TUTORS CHAIR_F
Cardinality Ratios
Constrains the number of entities that can
participate in each role of the relationship
N MAJOR_D 1
STUDENT DEPT
MINOR_D
1
Tutor Tutee
TUTORS CHAIR_F
Cardinality Ratios
Constrains the number of entities that can
participate in each role of the relationship
N MAJOR_D 1
STUDENT DEPT
N M
MINOR_D
1
Tutor Tutee
TUTORS CHAIR_F
Cardinality Ratios
Constrains the number of entities that can
participate in each role of the relationship
N MAJOR_D 1
STUDENT DEPT
N M
MINOR_D
1
Tutor Tutee
N M
TUTORS CHAIR_F
FACULTY
Structural Constraints
If an entity does not exist unless it appears with an entity in a
relationship, the participation is total (existence dependency).
Else, partial.
N MAJOR_D 1
STUDENT DEPT
N M
MINOR_D
1
Tutor Tutee
N M
TUTORS CHAIR_F
Structural Constraints
If an entity does not exist unless it appears with an entity in a
relationship, the participation is total (existence dependency).
Else, partial.
N MAJOR_D 1
STUDENT DEPT
N M
MINOR_D
1
Tutor Tutee
N M
TUTORS CHAIR_F
Attributes of Relationships
1->1, can go to either entity
1->N, can go to (1) entity
N MAJOR_D 1
STUDENT DEPT
N M
MINOR_D
1
Tutor Tutee
N M
TUTORS Office CHAIR_F
1
Each department chair has an office.
FACULTY
Attributes of Relationships
1->1, can go to either entity
1->N, can go to (1) entity
Done
N MAJOR_D 1
STUDENT DEPT
N M
MINOR_D
1
Tutor Tutee
N M
TUTORS Office CHAIR_F
1
It is important to know whether or
not a student has completed his/her FACULTY
major.
Attributes of Relationships
1->1, can go to either entity
1->N, can go to (1) entity
Done
N MAJOR_D 1
STUDENT DEPT
N M
MINOR_D
1
Tutor Tutee
N M
TUTORS Done Office CHAIR_F
1
It is important to know whether or
not a student has completed each of FACULTY
his/her minor(s).
Attributes of Relationships
1->1, can go to either entity
1->N, can go to (1) entity
Done
N MAJOR_D 1
STUDENT DEPT
N M
MINOR_D
1
Tutor Tutee
N M
TUTORS Done Office CHAIR_F
Subject
1
It is important to know the subject(s)
in which a tutee is being tutored by FACULTY
each tutor.
Weak Entities
Entity types that do not have key attributes
of their own are weak; instead identified by
relation to specific entity of another type
(the identifying type)
Prof
1 COURSE N
COURSE SEC SECTION
DEPT NUM
Revise!
We store each employee’s
name (first, last, MI), Social
Security number (SSN), street
address, salary, sex (gender),
and birth date. An employee is Salary)
Answer
Salary
1
Supervisor Birthdate
Supervision
EMPLOYEE
Address
Supervisee
N
FName Name Works_On Project
MI LName Hours
Revise!
Salary)
Supervision)
Birthdate)
EMPLOYEE)
the employee.
Employee(
DEPENDENT( DBirthdate(
Rela7onship(
DName(
Answer
Salary
Supervisor
Birthdate
Supervision
EMPLOYEE
Address
Supervisee
1
N
Sex
MI LName Hours
DEPENDENT N
DEPENDENT DBirthdate
_OF
Relationship
DName
Revise!
A department controls Name' Number'
Manager_'
Start_Date'
Answer
Name Number
Location PROJECT
Name Number
N
1
CONTROLS DEPARTMENT Manager
Manager_
Location
Start_Date
Revise!
Name' Number'
1'
An employee is assigned
CONTROLS' DEPARTMENT' Manager'
necessarily controlled by
SSN) Sex) Department)
1)
Supervision)
EMPLOYEE)
RelaIonship)
DName)
Answer
Supervisor Supervisee
1 N
Hours Supervision
M
WORKS_ON EMPLOYEE SSN
1 N
Name
Start
_Date
N
Number
1
1 1
CONTROLS DEPARTMENT Works_For
Name Number
Location
Specialization/Generalization
Only a subset of entities within a type have
certain attributes or participate in certain
relationships
ID
STUDENT
GRAD_STUDENT Degrees
A person can be an
employee, an
PERSON
alumnus, and/or a
student
o
U
U
A person can be
either an employee,
PERSON
an alumnus, or a
student
d
U
U
A person must be
exactly one: an
PERSON
employee, an
alumnus, or a student
d
U
U
Exercise
• The database keeps track of three types of persons: employees, alumni, and students. A
person can belong to one, two, or all three of these types. Each person has a name, SSN,
sex, address, and birth date.
• Every employee has a salary, and there are three types of employees: faculty, staff, and
student assistants. Each employee belongs to exactly one of these types. For each
alumnus, a record of the degree or degrees that he or she earned at the university is kept,
including the name of the degree, the year granted, and the major department. Each
student has a major department.
• Each faculty has a rank, whereas each staff member has a staff position. Student
assistants are classified further as either research assistants or teaching assistants, and
the percent of time that they work is recorded in the database. Research assistants have
their research project stored, whereas teaching assistants have the current course they
work on.
• Students are further classified as either graduate or undergraduate, with the specific
attributes degree program (M.S., Ph.D., M.B.A., and so on) for graduate students and
class (freshman, sophomore, and so on) for under- graduates.
Answer
Requirements Elicitation
The conceptual model should inform requirements elicitation questions:
View Integration
– Each stakeholder implements local view
– Individual views integrated into global
schema
– Individual views can be reconstructed as
external schemas after integration
Entity-Relationship (ER) Diagrams
Summary
• The goal of conceptual design is to develop a set
of data requirements that are comprehensive,
clear & easy to understand, and algorithmically
transformable