Академический Документы
Профессиональный Документы
Культура Документы
Step 1: Mapping Regular Entities to Relations Step 2: Mapping Weak Entities Step 3: Mapping Binary Relationships 3 Step 4: Mapping Associative Entities Step 5: Mapping Unary Relationships Step 6: Mapping Ternary (and n-ary) Relationships Step 7: Mapping Super type/Sub type Relationships Step 8: Mapping of Union Types(Categories)
Associative Entities
An entityhas attributes A relationshiplinks entities together When should a relationship with attributes instead be an associative entity?
All relationships for the associative entity should be many The associative entity could have meaning independent of the other entities The associative entity preferably has a unique identifier, and should also have other attributes The associative entity may participate in other relationships other than the entities of the associated relationship Normally Ternary relationships should be converted
Identifier Assigned, because 1)It is natural and familiar to end-users or 2) Default identifier may not be unique
Use identifier as primary key The primary key of the two participating entity types becomes foreign key in the associative entity
Figure 5-16 Example of mapping an associative entity with an identifier (cont.) b) Three resulting relations
10
Mapping a ternary relationship a) PATIENT TREATMENT Ternary relationship with associative entity
11
Mapping a ternary relationship (cont.) b) Mapping the ternary relationship PATIENT TREATMENT
This is why treatment date and time are included in the composite primary key
13
Supertype/subtype relationships
14
15
COMPANY
OWNER M OWNS N
LienOrRegular PurchaseDate
U
TRUCK
CAR
OwnerID
OwnerID
REG_VEHICLE
VehicleID
LicensePlateNumber
CAR
VehicleID
Cstyle
Cmake
Cmodel
CYear
TRUCK
VehicleID
Tmake
Tmodelt
Tonnage
TYear
OWNS
OwnerID
VehicleID
PurchaseDate
LineOrRegular