Roles in Relationships

Roles in Relationships

It is possible that one entity set appears two or more times in a single relationship. If so, we draw as many lines from the relationship to the entity set as the entity set appears in the relationship. Each line to the entity set represents a different role that the entity set plays in the relationship. We therefore label the edges between the entity set and relationship by names, which we call "roles".

a relationship with roles
Example : In the above figure is a relationship Sequel-of between the entity set Movies and itself. Each relationship is between two movies, one of which is the sequel of the other. To distinguish between the two movies in a relationship, one line is labeled by the role Original and one by the role Sequel, indicating the original movie and its sequel, respectively. We suppose that a movie may have many sequels, but for each sequel there is only one original movie. Thus, the relationship is many-one from Sequel movies to Original movies, as indicated by the arrow in the E/R diagram of above figure.

Example : As a last example that includes both a multiway relationship and an entity set with multiple roles, in the following figure is a more complicated version of the Contracts relationship introduced earlier in "Multiway Relationships" example. Now, relationship Contracts involves two studios, a star, and a movie. The intent is that one studio, having a certain star under contract (in general, not for a particular movie), may further contract with a second studio to allow that star to act in a particular movie. Therefore, the relationship is explained by 4-tuples of the form (studio1, studio2, star, movie), meaning that studio2 contracts with studio1 for the use of studio1's star by studio2 for the movie.
A four-way relationship
We see in the above figure arrows pointing to Studios in both of its roles, as "owner" of the star and as producer of the movie. However, there are not arrows pointing to Stars or Movies. The fundamental reason is as follows. Given a star, a movie, and a studio producing the movie, there can be only one studio that "owns" the star. (We assume a star is under contract to exactly one studio.) Likewise, only one studio produces a given movie, so given a star, a movie, and the star's studio, we can determine a unique producing studio. Note that in both cases we in reality required only one of the other entities to decide the unique entity - for example, we need only know the movie to decide the unique producing studio - but this fact does not change the multiplicity specification for the multiway relationship.

There are no arrows pointing to Stars or Movies. Given a star, the star's studio, and a producing studio, there could be numerous different contracts allowing the star to act in several movies. Thus, the other three components in a relationship 4-tuple do not necessarily decide a unique movie. Likewise, a producing studio might contract with some other studio to use more than one of their stars in one movie. In this way, a star is not decided by the three other components of the relationship.

Limits on Arrow Notation in Multiway Relationships

There are not enough choices of arrow or no-arrow on the lines attached to a relationship with three or more participants. In this way, we cannot explain every possible situation with arrows. For example, in "Multiway Relationships" figure, the studio is in fact a function of the movie alone, not the star and movie jointly, since only one studio produces a movie. Nevertheless, our notation does not differentiate this situation from the case of a three-way relationship where the entity set pointed to by the arrow is truly a function of both other entity sets. In "Functional Dependencies" we shall take up a formal notation - functional dependencies - that has the ability to explain all possibilities about how one entity set can be decided distinctively by others.

Tags