Relationships and Relationship Sets
What You'll Learn
You'll learn how to model associations between entities using relationships and understand what relationship instances represent in an ER model.
Understanding Relationships
In ER modeling, entities rarely exist in isolation—they interact with and relate to one another. A relationship is a meaningful association between two or more entity sets. A relationship set is the collection of all relationship instances of the same type.
Think of it like connections on social media: if "Person" is an entity set, "follows" would be a relationship. Each specific instance—like "Alice follows Bob"—is one relationship instance in the "follows" relationship set.
How Relationships Work
A relationship connects specific entity instances. For example:
- Entity sets: Student and Course
- Relationship: Enrolls
- Relationship instances: "Student #101 enrolls in CS101", "Student #102 enrolls in MATH200"
The relationship set "Enrolls" contains all these individual enrollment connections between students and courses.
Key Properties
Relationships can:
- Connect two entity sets (binary relationships, most common)
- Connect three or more entity sets (ternary, n-ary relationships)
- Connect an entity set to itself (recursive relationships, like "Person manages Person")
Each relationship has a degree—the number of entity sets participating. "Enrolls" connecting Student and Course has degree 2.
Relationships can also have their own attributes. For example, the "Enrolls" relationship might have an "enrollment_date" attribute describing when that specific student enrolled in that specific course.
Key Takeaway: Relationships model associations between entities, and relationship sets are collections of all relationship instances of the same type—they capture the "verbs" connecting the "nouns" in your database design.