Cardinality


Note

Note that this section refers to cardinality as maxima and minima of relationships and attributes. Section 4.3: Binary relationships uses a slightly different terminology, with cardinality as the maxima of relationships and attributes, while modality is the minima of relationships and attributes. Both sets of terminology are used widely.

Relationship Maximum

In entity-relationship modeling, cardinality refers to maxima and minima of relationships and attributes.

Relationship maximum is the greatest number of instances of one entity that can relate to a single instance of another entity.

  • relationship has two maxima
    • one for each of the related entities
  • Maxima are usually specified as one or many
  • A related entity is:
    • singular when the maximum is one
    • plural when the maximum is many
  • maximum of one is shown as a short bar across the relationship line
  • Maximum of many is shown as three short lines that converge at a point
    • called crow’s foot notation
  • Fixed numeric maxima are documented in the glossary

Relationship Minima

Relationship minimum is the least number of instances of one entity that can relate to a single instance of another entity.

  • relationship has two minima,
    • one for each of the related entities
  • Minima are usually specified as zero or one
  • A related entity is:
    • optional when the minimum is zero
    • required when the minimum is one
  • minimum of one is shown as a short bar across the relationship line
  • Minimum of zero is shown as a circle
  • Maxima symbols always appear next to the entity
  • Minima symbols appear farther from the entity
  • can have a minimum greater than one
    • Minima greater than one are documented in the glossary

Attribute Maximum and Minimum

Attribute maximum is the greatest number of attribute values that can describe each entity instance.

  • specified as
    • one (singular)
    • or many (plural)

Attribute minimum is the least number of attribute values that can describe each entity instance.

  • specified as
    • zero (optional)
    • or one (required)
  • Attributes are presumed singular and optional
    • a “P” following the attribute indicates it is plural
    • “R” indicates required
  • Numeric minimum and maximum are documented in the glossary

Unique Attributes

Each value of a unique attribute describes at most one entity instance.

  • e.g. Vehicle identification number (VIN) is a unique attribute of Vehicle
  • Occasionally, a composite of several attributes is unique, although the individual attributes are not
  • Unique is not the same as a singular:
    • unique attribute has at most one entity instance for each attribute value
    • singular attribute has at most one attribute value for each entity instance
  • attributes are presumed not unique
    • A “U” indicates the attribute is unique
    • Unique composite attributes are grouped with a brace before the “U” symbol

Entity-Has-Attribute Relationship

Entities have an implicit relationship with their attributes, called Entity-Has-Attribute.

  • attribute maxima and minima are the cardinality of Attribute in this relationship
  • e.g., VIN is a required attribute of vehicle
    • in relationship Vehicle-Has-VIN,
      • every vehicle must have a VIN
  • an attribute is unique when Entity is singular in this relationship
    • e.g., each VIN has at most one vehicle
    • so VIN is unique attribute of Vehicle

Database Design

  • Relationship and attribute cardinality depends on business rules
  • During the conceptual design phase
  • Depending on the desired level of detail,
    • cardinality does not always appear on ER diagrams
  • ER diagrams are drawn with software tools that can automatically show or hide cardinality

Determine Cardinality

StepActivity
2ADetermine relationship maxima and minima.
2BDetermine attribute maxima and minima.
2CIdentify unique attributes.
2DDocument cardinality in glossary and, optionally, on ER diagram.