| Lesson 9 | Many-to-many Relationships (In Depth) |
| Objective | Identify many-to-many relationships from requirements, notation, and data symptoms. |
A relationship is many-to-many (M:N) when one instance of entity A can be related to zero, one, or many instances of entity B, and one instance of B can be related to zero, one, or many instances of A.
A student may enroll in many classes;
a class may have many enrolled students.
Quantity on an order line, Role on a project team, EnrolledOn for a student’s class.|<{ —— }>|) with optionality shown by O (optional) or | (mandatory).0..* ↔ 0..*.Class1, Class2, Class3….Quantity in Order or Product rather than on the connection.Given the constraints:
These two statements together indicate an M:N between Student and Class. The figures below illustrate why treating this as a direct link causes redundancy and ambiguity.
ClassID in Student looks plausible but fails when a student has multiple classes.
ClassName values, repeated student rows).
Degree is the number of participating entities (binary = 2, ternary = 3). Most modeling uses binary relationships. Connectivity is the maximum mapping (1 or many); cardinality annotations (e.g., 0..*, 1..3) refine minimum/maximum participation.
Recursive and higher-degree (ternary) cases can also be M:N; in practice, they are decomposed into binary relationships for implementation.
Conceptually, you may draw an M:N without choosing a “parent.” When moving toward implementation, you will introduce an associative (intersection) entity to hold the pairs and any attributes of the association (e.g., Quantity, PriceAtOrder, Role, EnrolledOn).
0..*?Quantity, UnitPrice).Role, Hours).Sequence, Contribution%).Many-to-many relationships are common in business (including the DistributedNetworks examples). Identification is the first step; physical resolution (via a junction entity) is covered in the next lesson.
Summary: You have an M:N when both sides can have many, the relationship needs its own attributes, and notation shows “many” on both ends. Recognize these early to avoid redundancy and to prepare for proper implementation with an associative entity.