Share via


Entity Data Model Relationships

A relationship is a logical connection between two or more entities. Meaningful data in an application includes relationships among its constituent parts. Relationships are essential to data modeling, yet the relational database model does not explicitly support relationships. Instead, primary keys, foreign keys, and referential integrity are used to implement some of the constraints implied by relationships.

In contrast, the Entity Data Model (EDM) provides explicit support for relationships in the data model, which results in flexible modeling capabilities. Relationship support extends to EDM queries, permitting explicit referencing and navigation based on relationships.

The EDM supports a peer-to-peer relationship model called an association. For the details, see Association (EDM).

The need for associations is clear in the following situations: a customer makes one or more orders; each order contains order details identifying the products ordered; the products ordered are available from one or more suppliers; and so on.

In the EDM, associations between entities are specified in the schemas in which the entities and associations are defined.

Characteristics of Relationships

Relationships are characterized by degree, multiplicity, and direction. In data modeling scenarios, relationships have degree (unary, binary, ternary, or n-ary), and multiplicity (one-to-one, one-to-many, or many-to-many). Direction can be significant in some associations, if, for example, the association is between entities of the same type.

The characteristics of relationships are shown in the following diagrams.

Unary Relationship Diagram Binary Relationship Diagram Ternary Relationship Diagram

The degree of the relationship in each diagram is represented by the number of rectangles. Relationships are represented by diamond-shaped figures. The lines between the diamonds and the rectangles represent the multiplicity of the relationships. A single line represents a one-to-one relationship. A line that branches into three segments where it connects to the type represents the many ends of one-to-many or many-to-many relationships.

Degree

The degree of a relationship is the number of types among which the relationship exists. The most common degree of relationship is binary, which relates two types. In a unary relationship one instance of a type is related to another instance of the same type, such as the manager relationship between an employee and another employee. A ternary relationship relates three types and an n-ary relationship relates any number (n) of types. Ternary and n-ary relationships are mainly theoretical. The EDM supports unary and binary relationships.

Multiplicity

Multiplicity is the number of instances of a type that are related.

A binary relationship exists between a book and its author, for example, where each book has at least one author. The relationship is specified between the class Book and the class Author, but the multiplicity of this relationship is not necessarily one book to one author. The multiplicity of the relationship indicates the number of authors a book has and the number of books each author has written. The degree of the relationship in this example is binary. The multiplicity of the relationship is many-to-many.

Direction

In the EDM, all relationships are inverse relations. An EDM association can be navigated starting from either end.

If the entities at the ends of an association are both of the same type, the role attribute of the EDM association End property can be used to specify directionality. An association between an employee and the employee's manager is semantically different from the two ends of the association. Both ends of the association are employees, but they have different Role attributes. For an example that implements this case using a referential constraint, see Association Element (SSDL).

The following topics contain more information about relationships.

In This Section

See Also

Concepts

Entity Data Model Types
Implementing Entities (EDM)
Implementing Associations (EDM)