ER Diagrams   «Prev  Next»

Lesson 9 Many-to-many Relationships (In Depth)
Objective Identify many-to-many relationships from requirements, notation, and data symptoms.

Identify Many-to-Many (M:N) Relationships

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.

How to recognize an M:N from requirements

  • Symmetric “many” phrasing: Requirements describe “many on both sides,” e.g., employees work on many projects; projects have many employees.
  • No clear ownership: Neither side naturally “owns” the other (contrast with 1:N where one side aggregates the other).
  • Business facts about the association: You hear attributes that apply to the pairing, e.g., Quantity on an order line, Role on a project team, EnrolledOn for a student’s class.

How to recognize an M:N in notation

  • Crow’s Foot: a crow’s foot on both ends (|<{ —— }>|) with optionality shown by O (optional) or | (mandatory).
  • UML: multiplicities 0..*0..*.
  • Chen: relationship diamond with “M” next to each participating entity.

How to recognize M:N from data symptoms

  • Repeating groups / arrays in a column: comma-separated IDs or names indicate “many” packed into one field.
  • Repeating columns: patterns like Class1, Class2, Class3….
  • Duplicate rows: rows duplicated just to record another related item.
  • Misplaced attributes: putting Quantity in Order or Product rather than on the connection.

Worked example: Student–Class

Given the constraints:

  1. A student may enroll in many classes.
  2. A class may have many enrolled students.

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.

Assume Student and Class are directly related (not allowed physically, shown for illustration).
1) Conceptual M:N: Student and Class are directly related (concept only).

ClassID inserted into Student to form a link.
2) Attempting to place ClassID in Student looks plausible but fails when a student has multiple classes.

Adding ClassName into Student to identify enrolled classes.
3) Adding multiple class attributes/values in Student creates repeating groups and redundancy.

Populated STUDENTs table shows redundant ClassName values.
4) With data, redundancy becomes obvious (duplicate ClassName values, repeated student rows).

Redundancy visible in STUDENTs table—root cause of M:N problems.
5) Redundancy and ambiguity (which class pairs with which timestamp/grade?) are classic M:N symptoms.

Degree, connectivity, and why it matters for M:N

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.

  • 1:1 — each A maps to at most one B and vice versa (rare; often a split table).
  • 1:N — A maps to many B; each B maps to one A (most common).
  • M:N — many on both sides (what we’re detecting here).

Recursive and higher-degree (ternary) cases can also be M:N; in practice, they are decomposed into binary relationships for implementation.

Conceptual modeling note

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).

Conceptual M:N: Order sells Product.
Figure 6-9: Conceptual M:N — “Order sells Product.” In physical design, this becomes two 1:N links via an OrderLine (junction) table.

Quick self-check: Is it M:N?

  • Do requirement sentences use plural on both sides? (orders contain products; products appear on orders)
  • Would storing the link in either parent force repeating groups or duplicate rows?
  • Are there attributes that clearly describe the pairing rather than either entity alone?
  • In your ERD, do both ends show crow’s feet or 0..*?

Additional examples

  • Orders ↔ Products (order lines carry Quantity, UnitPrice).
  • Employees ↔ Projects (assignment carries Role, Hours).
  • Authors ↔ Publications (authorship carries 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.


SEMrush Software 9 SEMrush Banner 9