Sei sulla pagina 1di 17

Associative Entities

Chapter 3
Modern Database Management,
7th Edition
Hoffer, Prescott, McFadden

Introduction

If you encounter many-to-many


relationships that have one or more
attributes associated with the relationship,
rather than with one of the participating
entity types, this suggests that you
consider converting the relationship to an
associative entity

Associative Entity
An entity type that associates the
instances of one or more entity types and
contains attributes that are peculiar to the
relationship between those entity
instances
It may have its own simple identifier (or
primary key) or they may be assigned a
composite identifier during logical design

Special Notation/Symbol

Diamond relationship symbol enclosed


within the entity box

The purpose of the symbol is to preserve


the information that the entity was initially
specified as a relationship on the ERD

Example
EmpID

EmpName

EMPLOYEE

CourseID
Date_Completed

CertificateNo

Completes

Date_Completed

CERTIFICATE

CourseTitle
A

COURSE

Associative entities are


sometimes referred to as
gerunds (verbal noun)
because the relationship
name (verb) is usually
converted to an entity
name (noun).

Cardinality Placement
Converting a relationship to an associative
entity has caused the relationship notation
to move
The many cardinality now terminates at
the associative entity, rather than at each
participating entity type

Example
identifier
CertificateNo

EmpID

Date_Completed

EmpName

A
EMPLOYEE

CourseTitle

CourseID

CERTIFICATE

Associative Entity

Cardinality terminates at the


associative entity

COURSE

Four (4) conditions

These conditions determine if you need to


convert a relationship to an associative
entity:

All the relationships for the participating entity


types are many relationships
The resulting associative entity type has
independent meaning to end users, and
preferably can be identified with a singleattribute identifier

Four (4) conditions


(continued)

The associative entity has one or more


attributes, in addition to the identifier
The associative entity participates in one or
more relationships independent of the entities
related in the associated relationship

Another Example:
Amount

Name

TransactionDate

ClientNo
CLIENT

AccountNo

Deposits/Withdraws

BankBranch

AccountName

CheckNo

BANKACCOUNT
Balance

Since the participating entities are involved in a many relationship


and the relationship has its own attributes, we can convert this into
an associative entity as shown on the next slide.

Conversion of the design


(in the previous slide)
STEP 1:
Place a rectangle on the relationship and change its name
into a noun that can be understood by the user.
Move the attributes and their connectors to point to the
rectangle border rather than to the diamond.
TransactionDate

Name

Amount
AccountName

ClientNo
CLIENT

AccountNo

TRANSACTION

BankBranch

CheckNo

BANKACCOUNT
Balance

STEP 2:
Transfer the cardinalities from the entities to the
associative entity

TransactionDate

Name

Amount
AccountName

ClientNo
CLIENT

AccountNo

TRANSACTION

BankBranch

CheckNo

BANKACCOUNT
Balance

TransactionDate

Name

Amount
AccountName

ClientNo
CLIENT

AccountNo

TRANSACTION

BankBranch

CheckNo

BANKACCOUNT
Balance

Place

a mandatory one on the original entities

TransactionDate
Amount
Name
ClientNo

CLIENT

AccountName

A
TRANSACTION

BankBranch

CheckNo

AccountNo

BANKACCOUNT
Balance

STEP 3:
Add an identifier to the associative entity
Add the primary keys of the related entities
TransactionDate
TransNo

ClientNo

AccountNo

Amount

Name
ClientNo

CLIENT

AccountName

A
TRANSACTION

BankBranch

CheckNo

AccountNo

BANKACCOUNT
Balance

Exercise

A hospital has a large


number of registered
physicians. Attributes
of PHYSICIAN include
PhysicianID (identifier),
and Specialization.
Patients are admitted to
the hospital by
physicians. Attributes
of PATIENT include
PatientID (identifier)
and PatientName. Any
patient who is admitted
must have exactly one
admitting physician. A
physician may
optionally admit any
number of patients.

Once admitted, a given


patient must be treated
by at least one
physician. A particular
physician may treat any
number of patients, or
may not treat any
patients. Whenever a
patient is treated by a
physician, the hospital
wishes to record the
details of the treatment
(TreatmentDetail).
Components of
TreatmentDetail include
Date, Time, and Results.

END OF PRESENTATION