Relationships and Cardinality in Data Models

Relationships show how business concepts connect and how many instances may participate.

BeginnerIntermediateExpert · 5 min read · Last updated:

In brief

A relationship states how two modeled concepts are connected. Cardinality describes how many instances may participate; optionality describes whether participation is required.

Common cardinalities

RelationshipExampleModeling note
One-to-oneEmployee to assigned badgeConfirm both sides really have a single instance
One-to-manyOrder to order linesEach line usually belongs to one order
Many-to-manyStudents to coursesOften needs an associative concept such as enrollment
RecursiveEmployee reports to employeeDefine roots, cycles and hierarchy behavior

Optional or required

Ask the question in both directions. Can an order exist with no lines? Can a product exist before it appears on an order? The answer may differ by lifecycle stage. State whether the relationship is required now, required eventually, or optional.

Many-to-many relationships

When a relationship has attributes or its own lifecycle, model it as an associative entity. Enrollment may have a registration date, status and grade; it is more than a bare link between student and course. In a database, this often becomes a junction table with references to both sides.

Test the model

  • Does the relationship match an actual business rule?
  • Are minimum and maximum counts clear on both sides?
  • Can the relationship itself change or have descriptive attributes?
  • Are circular links and self-references controlled?
  • Can records be created in the order the process requires?
Implementation depth Examples, failure cases and review points

Read cardinality through real scenarios

Cardinality describes how many instances can participate in a relationship. In “one customer places many orders,” each order may belong to one customer, while one customer may place zero or many orders. State both directions. Also decide whether the relationship is mandatory: can an order exist before its customer assignment is known? These details affect validation, reporting and application behavior.

Consider a product and a supplier. A product may have several approved suppliers, and a supplier may provide many products. This is many-to-many, but the relationship often has its own facts: supplier product code, agreed price, lead time and validity dates. Model the association as a first-class entity when it has attributes, identity, lifecycle or history.

Distinguish optional from required

Optionality is a business rule, not a formatting preference. If every invoice must refer to a legal account, enforce that requirement where the invoice is created or validated. If a support interaction may arrive before identity resolution, permit an unresolved state and define how it is reconciled. Avoid using a nullable foreign key to mean several different things such as not yet known, not applicable and intentionally withheld.

Represent many-to-many and changing relationships

An associative entity or bridge structure represents each link explicitly. It can carry link-specific attributes and allow multiple periods of association. For example, an employee may be assigned to multiple projects over time; each assignment can have start and end dates, role and allocation. Define whether overlapping assignments are valid and whether a closed assignment can be reopened or must be corrected.

Historical relationships require clear time semantics. “Current manager” may be enough for a live directory, but a compensation report may need the manager valid when an event occurred. Store effective periods or immutable change events according to the use case, and make interval boundaries precise. Test adjacent periods for gaps and overlaps.

Avoid join multiplication

A join can multiply rows when the relationship is one-to-many or many-to-many. Summing order value after joining both order lines and payments may count the order multiple times. State the grain of each dataset and inspect the relationship before aggregating. Use explicit allocation rules when a measure must be distributed across multiple related entities; do not duplicate the full value for each link unless that is the intended measure.

A quick test

Write one sentence for each side: “One ___ can relate to zero, one or many ___.” Then create a minimal example with two children. If a query returns twice the expected parent measure, the join path or aggregation grain needs review.

  • Are both relationship directions documented?
  • Are minimum and maximum counts clear?
  • Does the relationship have attributes or history of its own?
  • Can unknown or unresolved links be represented honestly?
  • Have joins been tested for duplicate matches and measure multiplication?

For implementation constraints, see Keys, Identifiers and Referential Integrity and Fact Table Grain and Measurement Types.

Validate relationships in implementation

Translate each relationship into keys and constraints that match the declared cardinality. Check uniqueness at the referenced grain and verify required parents exist. For optional relationships, distinguish an unknown reference from a valid absence. Use test data for zero, one, and multiple related records.

When cardinality changes, assess queries and consumer assumptions. A new many-to-many link may multiply measures or require an associative entity. Document the change and add integrity checks to prevent accidental duplicates.

Review cardinality changes

Changing one-to-one to one-to-many or adding a bridge affects constraints, queries, measures, and consumer assumptions. Identify impacted code and test representative joins. Decide how existing duplicates or missing links are handled.

Publish migration notes and update diagrams, schema, and quality checks together.