Escolar Documentos
Profissional Documentos
Cultura Documentos
Requirements
ER Diagram
University Enterprise
Requirements
University Enterprise
ERD - WHAT
University Enterprise
Textual Analysis: Entities & Attributes
E1
E2
E3
E4
4 17
University Enterprise
ERD: Entities & Attributes
Error found; need a more rigorous approach
E1
E2
E4
E3
R1
R1
R2
R3 R4
R5
R6
R8
R7
R1
R6 R5 R4 R3
R7
R8
How - Relational
SQL
?????
Database System Concepts - 5th Edition, July 11, 2005 6.21 ©Silberschatz, Korth and Sudarshan
Entity Relationship Diagram
Requirements
Pharmacy Enterprise (Exercise 2.7) ER Diagram
Pharmacy Enterprise (Exercise 2.7) ER Diagram
HOW?
Database 1 Case Study
Requirements
XYZ Marketing Agency wants to track the
following information about drinkers (can be
buddies or husband and wifes) in bars and the
beers they like made by which beer
manufacturers.
Beers
ER Diagrams
In an Entity Relationship Diagram:
Entity set = rectangle.
Attribute = oval, with a line to the rectangle representing its entity set.
name manf
Beers
Example
name manf
Beers
Employees
license
For the Relationship Sells, we might
have a Relationship set values like:
Bar Beer
Joe’s Bar Bud
Joe’s Bar Miller
Sue’s Bar Bud
Sue’s Bar Pete’s Ale
Sue’s Bar Bud Lite
ER Model Basics name
name
ssn lot
ssn lot
since Employees
Employees
name dname
super- subor-
ssn lot did budget super-
visor subor-
visor dinate
dinate
Reports_To
Employees Works_In Departments Reports_To
Database
Q: Management
How many attributesSystems 3ed, R. Ramakrishnan
does Works_In has? and J. Gehrke
A: 3 37
Multiway Relationships
Preferences
Drinkers
name addr
Q: How many attributes does Preferences has? A: 3
name addr name manf
Drinkers
Preferences name addr
Bar Drinker Beer
Joe’s Bar Ann Miller
Sue’s Bar Ann Bud
Joe’s Bar Bob Bud
Joe’s Bar Bob Miller
Sue’s Bar Cal Bud Lite
Many-Many Relationships
Favorite
Consider Works_In:
An Employee can work in many Departments;
A Department can have many Employees.
Many-to-Many
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 46
Key Constraints since
name dname
ssn lot did budget
In contrast:
Each department has at most one manager, according to the key
constraint on Manages.
1-to-Many
Textbook
“TEXTUAL
Database Notation
ANALYSIS
Management MUST
REQUIRED
Systems 3ed, BE USED
NOTATIONS
R. Ramakrishnan in
forHomeworks,
ERD Analysis or Projects
and J. Gehrke Data WHAT.docx”
47
Key Constraints
since
name dname
ssn lot did budget
Database
Q: Management
How many attributesSystems 3ed, R. Ramakrishnan
does Manages has? and J. Gehrke
A: 3 48
Participation Constraints
Does every Department have a Manager?
If so, this is a participation constraint: the participation of
Departments in Manages is said to be total (vs. partial).
• Every did value in Departments table must appear in a
row of the Manages table (with a non-null ssn value!)
since
name dname
ssn lot did budget
Works_In
since
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 49
1. Given the Chen ERD below,
describe the Relationships (identify the business rules), by filing in the boxes:
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke Class Participation 501
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 51
Weak Entity Sets
Plays- ?????
Players Teams
on
name
cost pname age
ssn lot
SEE
“TEXTUAL ANALYSIS REQUIRED NOTATIONS for ERD Analysis or Data WHAT.docx”
Subclasses
?????
Subclasses in ER Diagrams
isa
Example
isa ?????
color Ales
ER vs. Object-Oriented Subclasses
Pete’s Ale
isa
color Ales
ISA (`is a’) Hierarchies ssn
name
lot
considered to be a B entity.
hourly_wages hours_worked
ISA
contractid
Hourly_Emps Contract_Emps
isa
color Ales
Example: a Multi-attribute Key
dept number hours room
Courses
Note that hours and room could also serve as a key, but we must
select only one key.
Avoid redundancy.
Limit the use of weak Entity Sets.
Don’t use an Entity Set when an attribute will do
Avoiding Redundancy
Redundancy occurs when we say the same
thing in two or more different ways.
Example: Good
name name addr
Example: Bad
name name addr
manf
Beers
Beers
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?
Purchaser
Beneficiary
policyid cost
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 84
Binary vs. Ternary Relationships
Previous example illustrated a case when two binary
relationships were better than one ternary relationship.
90
2. Given the Requirement below, perform Textual Analysis to identify the Entities
and Relationships:
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke Class Participation 912
2. Given the Requirement below, perform Textual Analysis to identify the Entities
and Relationships:
2. Given the Requirement below, perform Textual Analysis to identify the Entities
and Relationships:
R2: Manages
M E1: Employee “Manages” M E2: Department
R2: Manages
Rearrange
M E1: Employee “Manages” M E2: Department
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke Class Participation 942
Summary of Conceptual Design – WHAT
Conceptual Design follows requirements analysis
(TEXTUAL ANALYSIS is a MUST!!!!)
Yields a high-level description of data to be stored
Note:
Database There are many variations on
Management Systems 3ed, R. Ramakrishnan and J. Gehrke
ER model. 95
Summary of ER
Several kinds of integrity constraints can be expressed
in the ER model: key constraints, participation
constraints, and overlap/covering constraints for ISA
hierarchies. Some foreign key constraints are also
implicit in the definition of a Relationship Set.
EMPLOYEE
DEPENDENT