Attributes on Relationships

Attributes on Relationships

Occasionally it is convenient, or even necessary, to connect attributes with a relationship, rather than with any one of the entity sets that the relationship connects. For instance, consider the relationship of "Multiway Relationships" figure, which represents contracts between a star and studio for a movie. (Here, we have reverted to the earlier concept of three-way contracts in "Multiway Relationships" example, not the four-way relationship of "Roles in Relationships" example) We might wish to record the salary related with this contract. However, we cannot relate it with the star; a star might get different salaries for different movies. Likewise, it does not make sense to relate the salary with a studio (they may pay different salaries to different stars) or with a movie (different stars in a movie may receive different salaries).

A relationship with an attribute

However, it is suitable to relate a salary with the

                 (star, movie, studio)

triple in the relationship set for the Contracts relationship. In the above figure we see "Multiway Relationships" figure fleshed out with attributes. The relationship has attribute salary, while the entity sets have the same attributes that we showed for them in "Entity-Relationship Diagrams" figure.

It is never necessary to place attributes on relationships. We can instead invent a new entity set, whose entities have the attributes assigned to the relationship. If we then incorporate this entity set in the relationship, we can leave out the attributes on the relationship itself. However, attributes on a relationship are a useful convention, which we shall continue to use where appropriate.

Example : Let us revise the E/R diagram of above figure, which has the salary attribute on the Contracts relationship. Instead, we make an entity set Salaries, with attribute salary. Salaries becomes the fourth entity set of relationship Contracts. The whole diagram is shown in "Converting Multiway Relationships to Binary" figure.


Tags