Relationship Attributes
In an ER model, sometimes the relationship itself (not just the entities) needs to store additional information.
- These extra pieces of information are called relationship attributes.
- They describe properties of the association between entities.
- Represented as ovals attached to the relationship diamond (in Chen notation).
Why Do We Need Relationship Attributes?
Normally, attributes belong to entities. But in some cases:
- An attribute cannot be assigned to just one entity.
- Instead, it belongs to the relationship itself.
Example:
In a Student–Course enrollment system:
- Entities:
student,course. - Relationship:
enrolls. - Attribute:
grade.
The grade cannot belong only to student (different grades in different courses), nor only to course (different grades for different students).
It makes sense only as part of the enrollment relationship.
Example of Relationships
Entities & Attributes
Student(student_id,Name)Course(course_id,Title)
Relationship:
- Enrolls (between Student and Course)
- Relationship Attribute: Grade
ER Representation (text-based):
[STUDENT] ──(Enrolls)── [COURSE]
|
(Grade)
Grade is stored as part of the relationship, because it belongs to the association of a student with a course.
Important Notes about Relationship Attributes
-
They are used only when the attribute cannot be assigned to one entity alone.
-
In relational databases, relationship attributes are usually stored in a separate table (junction/associative entity).
- Example:
Enrollment(student_id, course_id, Grade)
- Example:
When to Use Relationship Attributes
- Many-to-Many relationships (M:N) often require relationship attributes.
- Sometimes in 1:N relationships, if extra information about the relationship needs to be stored.