associative entities

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

Upload: xavierjohanis

Post on 10-Dec-2015

214 views

Category:

Documents


0 download

DESCRIPTION

Silliman University - Uytengsu Foundation Computer Science Department

TRANSCRIPT

Page 1: Associative Entities

Associative Entities

Chapter 3Modern Database Management,

7th EditionHoffer, Prescott, McFadden

Page 2: Associative Entities

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

Page 3: Associative Entities

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

Page 4: Associative Entities

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

Page 5: Associative Entities

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

Page 6: Associative Entities

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

Page 7: Associative Entities

Example

CERTIFICATE

EmpIDEmpName

CertificateNo

CourseID

CourseTitleDate_Completed

Associative Entity

EMPLOYEE COURSE

identifier

Cardinality terminates at the associative entity

A B

Page 8: Associative Entities

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

Page 9: Associative Entities

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

Page 10: Associative Entities

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.

Page 11: Associative Entities

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.

Page 12: Associative Entities

CLIENT BANKACCOUNTTRANSACTION

ClientNo

NameTransactionDate

AccountNo

AccountName

Amount

Balance

BankBranch CheckNo

B A

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

Page 13: Associative Entities

CLIENT BANKACCOUNTTRANSACTION

ClientNo

NameTransactionDate

AccountNo

AccountName

Amount

Balance

BankBranch CheckNo

B A

Page 14: Associative Entities

CLIENT BANKACCOUNTTRANSACTION

ClientNo

Name

AccountNo

AccountName

Amount

Balance

BankBranch CheckNo

A B

TransactionDate

•Place a “mandatory one” on the original entities

Page 15: Associative 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

Page 16: Associative Entities

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.

Page 17: Associative Entities

END OF PRESENTATION