Professional Documents
Culture Documents
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 2
name
name
ER Model Basics ssn lot
ER Model Basics (Contd.) ssn lot
Employees Employees
since
name dname
Entity: Real-world object distinguishable ssn lot did budget
super- subor-
visor
from other objects. An entity is described dinate
Manages.
since
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 6
name
ssn lot
A weak entity can be identified uniquely only by considering vAs in C++, or other PLs, hourly_wages hours_worked
ISA
the primary key of another (owner) entity. attributes are inherited. contractid
Owner entity set and weak entity set must participate in a one-to-
vIf we declare A ISA B, every A
many relationship set (one owner, many weak entities). Hourly_Emps Contract_Emps
entity is also considered to be a B
Weak entity set must have total participation in this identifying
relationship set. entity.
Overlap constraints: Can Joe be an Hourly_Emps as well as
a Contract_Emps entity? (Allowed/disallowed)
name Covering constraints: Does every Employees entity also have
ssn lot
cost pname age to be an Hourly_Emps or a Contract_Emps entity? (Yes/no)
Reasons for using ISA:
Policy Dependents
To add descriptive attributes specific to a subclass.
Employees
To identify entitities that participate in a relationship.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 7 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 8
name
ssn lot
Aggregation Employees
Conceptual Design Using the ER Model
Used when we have Design choices:
to model a Monitors until
Should a concept be modeled as an entity or an
relationship
attribute?
involving (entitity
sets and) a started_on since
dname
Should a concept be modeled as an entity or a
relationship set. pid pbudget did budget relationship?
Aggregation allows us Identifying relationships: Binary or ternary?
Projects Sponsors Departments
to treat a relationship Aggregation?
set as an entity set
for purposes of * Aggregation vs. ternary relationship: Constraints in the ER Model:
participation in v Monitors is a distinct relationship, A lot of data semantics can (and should) be captured.
(other) relationships.
with a descriptive attribute. But some constraints cannot be captured in ER
v Also, can say that each sponsorship diagrams.
is monitored by at most one employee.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 9 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 10
• If the structure (city, street, etc.) is important, e.g., we values of the descriptive
Works_In4 Departments
attributes for each instance of Employees
want to retrieve employees in a given city, address this relationship.
must be modeled as an entity (since attribute values Accomplished by
Duration
from to
are atomic). introducing new entity set,
Duration.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 11 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 12
Entity vs. Relationship Binary vs. Ternary Relationships
name
First ER diagram OK if ssn lot pname age
since dbudget
a manager gets a name dname If each policy is Employees Covers Dependents
separate discretionary ssn lot did budget owned by just 1
budget for each dept. employee, and Bad design Policies
Employees Manages2 Departments
What if a manager gets each dependent
policyid
a discretionary name is tied to the
cost
budget that covers ssn lot covering policy, name pname age
ssn lot
all managed depts? since dname first diagram is
Redundancy: dbudget Employees did budget Dependents
Employees
stored for each dept inaccurate.
managed by manager. Manages2 Departments What are the Purchaser
ISA Beneficiary
Misleading: Suggests additional
dbudget associated with
department-mgr This fixes the constraints in the
Managers dbudget Better design Policies
combination. problem! 2nd diagram?
policyid cost
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 13 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 14
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 15 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 16
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 17 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 18