ER Diagrams
ER Diagrams
Victor Matos
1
Phases of Database Design
Data
Requirements
Conceptual design begins with the
Specification of requirements
and results
collection of requirements and results
Conceptual
needed from the database (ER Diag.)
Design
Logical schema is a description of the
Conceptual Schema structure of the database (Relational,
Logical Network, etc.)
Design
Physical schema is a description of
Logical Schema
the implementation (programs, tables,
Physical
Design
dictionaries, catalogs
Physical Schema
2
Models
A data model is a collection of objects that
can be used to represent a set of data and
operations to manipulate the data
Conceptual models are tools for representing
reality at a very high-level of abstraction
Logical models are data descriptions that can
be processed by computers
3
Conceptual model:
Entity-Relationship Diagrams
Entities represent classes of real-world
objects. Person, Students, Projects, Courses
are entities of a University database
Relationships represent interactions
between two or more entities
N 1
Lives_In
Person City
Is_Born_In
N 1 4
Example:
Every employee works in at least one
project
Every project has employees working on it.
EMPLOYEE
N N PROJECT
SSN
WORKS_ON Name
Name
Code
Salary
5
Higher-Order Relationships
A relationship may involve more than two
entities
Day
6
Recursive relationships
Relationships could be mapped from one
entity to itself
Manager_Of
1
Employee Manages
N
Subordinate_To
7
Attributes
Attributes represent elementary properties of the
entities or relationships. The stored data will be
kept as values of the attributes
Lives_In
N 1
CITY
PERSON Moving_Date
Name
Ssn
Country
Name Birth_Date
Elevation
Profession
Population
Is_Born_In
N 1 8
Generalizations
• An entity could be seen from many different viewpoints
• Each viewpoint defines a set of roles in a generalization
• Example below uses SEX to classify the object “Person”
PERSON
Ssn
Name
Address
MAN FEMALE
Draft_Status Maiden_Name
9
Generalizations
A classification could be disjoint or
overlapping
An entity could have more than one
classification PERSON
Ssn
Name
Address
SEX JOB
Full_Time Part_Time
MAN FEMALE
Annual_Salary Hour_Rate
Draft_Status Maiden_Name
Department Weekly_Hours
10
Example: Department Store 1/2
STORES 1 CITIES
Store ID N LOCATED City Name
Address IN State
Manager ID HeadQtr Address
N
N
CUSTOMER
Customer Name
Address
HOLD IN-CITIES
Phone Number
Qty Held Qty_in_cities
N N
1
ITEMS
Item ID N N ORDERS N
ITEMS ORDERED
Description Order Number PLACE
Qty Ordered
Size Order Date
Color
12
Example: University Database
Professors work for only one department
Departments have many professors
Each course is taught by only one professor
Students make a plan or program of study
A course could meet in several rooms/times
Graduate students must have an advisor
Cities are categorized as resident/BirthPlace
Visiting prof. need an End/Start date
13
University Database
CITY 1 N PERSON DEPARTMENT 1
Name BIRTH_PLACE LastName Name Belongs_To
State Age Phone
N
N
RESIDENT N
PROFESSOR
STUDENT TenureStatus
Title
N
N
1
VISITING_
ENROLLED PLANNED N PROFESSOR
GRADUATE_STUDENT ADVISED_BY Start_Appointment
Semester Semester
Grade End_Appointment
N
N
COURSE
N 1
Title TAUGHT_BY
Description Semester
Credits
1
TIME N N ROOM
Day MEETS RoomNumber
Hour Building
University database 14
Soccer Database
A team has players, one coach, fans
Teams play according to a schedule
Teams need to practice in a Stadium
Attendance and scores must be recorded
15
Soccer Database
PERSON
Ssn
Name
Address
FAN
PLAYER COACH
Name
Uniform_Size Personal Record
Address
Shoe_Size Years Experience
Favorite Bar
N N 1
PLAYS
SUPPORTS MANAGES
_FOR
1 1
N
TEAM
Name
Location
Phone
N
N N PRACTICES
PLAY_
AGAINST
GAME
STADIUM
Number TAKES
Name
ATTENDS Attendance PLACE
Address
N N
Final Score N AT 1 Capacity
16
Date
Research Project Database
Some employees are researchers
Every project has a leader investigator
Every project must be funded by an agency
A project may include several topics
A topic could appear in several projects
Researchers must produce report(s)
Each employee must have a supervisor
17
Research Projects Database
RESEARCH REPORT
Number
Title
1 SUPERVISE N
N N S
ADDRESSES PRODUCES
N N
EMPLOYEE
RESEARCH PRINCIPAL SSN
RESEARCH TOPIC N N INVESTIGATOR1 Name
PROJECT 1
Code ON N Title
Name
Name
Code
WORKS
N _ON
N
FUNDED_BY
N
Amount
Date
Grant#
AGENCY
Name
Address
Contact Person 18
Contract-Supplies System 1/3
19
Contract-Supplies System 2/3
20
Contract-Supplies System 3/3
SUPPLIERS
Supplier Number
Name
Address
PROJECTS
NEGOTIATE
Project Number
Date of Contract
Project Data
N
1
CONTRACTS 1 N
Contract Number SUPPLIED AS
Text
NEEDED BY
TO SUPPLY N
Contract Price
Contract Amount
ORDERS
ITEMS N N
MADE OF Order Number
Item Number
Order QTY Date Required
Description
Date Completed
21
Manufacturing: Requisitions 1/3
22
Manufacturing: Requisitions 2/3
23
Manufacturing: Requisitions 3/3
PROJECTS 1 N TASKS
Project Number MADE OF Task Number
Project Data Task Data
1 1
REQUESTS FOR
N
N
SUPPLIERS
REQUISITION
N 1 Supplier
Item Number FROM
Number
Qty Requested
Supplier Data
N 1
CONTAINS SENDS
N N
MATERIAL ITEM
EQUIPMENT ITEM
Code
Code
Description
Description
Weight 24
Container
Job-Shop Accounting System 1/4
ASSEMBLY
27
Job-Shop Accounting System 4/4
CUSTOMER ACCOUNTS
S Account ID
Customer ID Date
Address Established
A1
USED IN A3
JOBS
Job Number
Starting Date USES
Ending Date PROCESSES
Total Cost Process ID
Process Data
CUT JOBS
PAINT JOBS
Cut Job ID
FIT JOBS Paint Job ID
Machine type
Fit Job ID Color
used
Labor time Volume CUT PROC
Material used PAINT PROC FIT PROC
Labor time Cut Proc ID 28
Laor time Paint Proc ID Fit Proc ID
Cuttong Type
Paint Method Fit Type
Machine Type