Attributes of Relationship Types
Attributes of Relationship Types
In the ER model, relationship types—just like entity types—can have attributes. These attributes describe properties that belong to the association itself, rather than to any single participating entity.
Why Do Relationships Need Attributes?
Some facts in the miniworld depend on how two (or more) entities are related, not on the entities individually.
Examples
-
The number of hours an employee works on a project
-
The date an employee started managing a department
These values cannot be correctly stored as attributes of only one entity in all cases.
Examples from the COMPANY Database
WORKS_ON Relationship
-
Relationship: EMPLOYEE ↔ PROJECT (M:N)
-
Attribute: Hours
➡️ The number of hours depends on the employee–project pair, not on either entity alone.
MANAGES Relationship
-
Relationship: EMPLOYEE ↔ DEPARTMENT (1:1)
-
Attribute: Start_date
➡️ The start date indicates when the management relationship began, not a property of just the employee or the department.
Migrating Relationship Attributes
Whether a relationship attribute stays with the relationship or moves to an entity depends on the cardinality of the relationship.
1:1 Relationships
-
Each entity participates in at most one relationship instance
-
Relationship attributes can be moved to either participating entity
Example:
-
MANAGES (1:1)
-
Start_date can be stored in:
-
EMPLOYEE (manager), or
-
DEPARTMENT
-
✔ Both choices are valid
✔ Decision is left to the schema designer
1:N Relationships
-
Relationship attributes can be moved only to the N-side entity
Example:
-
WORKS_FOR (1:N)
-
Attribute: Start_date (employee joining date)
✔ Stored in EMPLOYEE, not in DEPARTMENT
✔ Because each employee participates in only one WORKS_FOR instance
M:N Relationships
-
Relationship attributes cannot be moved to either entity
-
They must remain as relationship attributes
Example:
-
WORKS_ON (M:N)
-
Attribute: Hours
✔ Hours depends on both employee and project
✔ Must be stored in the relationship
Summary Table
| Relationship Type | Where Relationship Attributes Can Go |
|---|---|
| 1:1 | Either entity or the relationship |
| 1:N | Only on the N-side entity |
| M:N | Must remain in the relationship |
Key Takeaways
✔ Relationship types can have attributes
✔ These attributes describe associations, not entities
✔ Migration depends on cardinality constraints
✔ M:N relationship attributes must stay in the relationship
✔ Design choices in 1:1 and 1:N are often conceptual and subjective

Comments
Post a Comment