associative entities
DESCRIPTION
Silliman University - Uytengsu Foundation Computer Science DepartmentTRANSCRIPT
Associative Entities
Chapter 3Modern Database Management,
7th EditionHoffer, 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
EMPLOYEE COURSECompletes
EmpIDEmpName
Date_CompletedCourseID
CourseTitle
CERTIFICATE
CertificateNoDate_Completed Associative entities are
sometimes referred to as gerunds (verbal noun) because the relationship name (verb) is usually converted to an entity name (noun).
B A
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
CERTIFICATE
EmpIDEmpName
CertificateNo
CourseID
CourseTitleDate_Completed
Associative Entity
EMPLOYEE COURSE
identifier
Cardinality terminates at the associative entity
A B
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 single-attribute 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:
CLIENT BANKACCOUNTDeposits/Withdraws
ClientNo
NameTransactionDate
AccountNo
AccountNameAmount
BalanceBankBranch CheckNo
B A
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)
CLIENT BANKACCOUNTTRANSACTION
ClientNo
NameTransactionDate
AccountNo
AccountName
Amount
Balance
BankBranch CheckNo
B A
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.
CLIENT BANKACCOUNTTRANSACTION
ClientNo
NameTransactionDate
AccountNo
AccountName
Amount
Balance
BankBranch CheckNo
B A
STEP 2:•Transfer the cardinalities from the entities to the associative entity
CLIENT BANKACCOUNTTRANSACTION
ClientNo
NameTransactionDate
AccountNo
AccountName
Amount
Balance
BankBranch CheckNo
B A
CLIENT BANKACCOUNTTRANSACTION
ClientNo
Name
AccountNo
AccountName
Amount
Balance
BankBranch CheckNo
A B
TransactionDate
•Place a “mandatory one” on the original entities
CLIENT BANKACCOUNTTRANSACTION
ClientNo
Name
TransNo
AccountNo
AccountName
Amount
Balance
BankBranch CheckNo
A B
STEP 3:•Add an identifier to the associative entity•Add the primary keys of the related entities
TransactionDate ClientNoAccountNo
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