Subclasses in the E/R Model

Subclasses in the E/R Model

Often, an entity set includes certain entities that have special attributes not connected with all members of the set. If so, we find it useful to describe certain special-case entity sets, or subclasses, each with its own special attributes and/or relationships. We join an entity set to its subclasses using a relationship called isa (i.e., "an A is a B" expresses an "isa" relationship from entity set A to entity set B).

Replacing a multiway relationship by an entity set and binary relationships
An isa relationship is a special kind of relationship, and to stress that it is not like other relationships, we use for it a special notation. Each isa relationship is represented by a triangle. One side of the triangle is connected to the subclass, and the opposite point is attached to the superclass. Every isa relationship is one-one, although we shall not draw the two arrows that are linked with other one-one relationships.

Example (a) : Among the kinds of movies we might store in our example database are cartoons, murder mysteries, adventures, comedies, and many other special types of movies. For each of these movie types, we could define a subclass of the entity set Movies. For example, let us assume two subclasses: Cartoons and Murder-Mysteries. A cartoon has, in addition to the attributes and relationships of Movies an additional relationship called Voices that gives us a set of stars who speak, but do not appear in the movie. Movies that are not cartoons do not have such stars. Murder-mysteries have an additional attribute weapon. The connections among the three entity sets Movies, Cartoons, and Murder-Mysteries is shown in the following figure "Isa relationships in an E/R diagram".

While, technically, a collection of entity sets connected by isa relationships could have any structure, we shall limit isa-structures to trees, in which there is one root  entity set (e.g., Movies in the following figure "Isa relationships in an E/R diagram") that is the most general, with increasingly more specialized entity sets extending below the root in a tree.

Assume we have a tree of entity sets, joined by isa relationships. A single entity consists of components from one or more of these entity sets, as long as those components are in a subtree including the root. That is, if an entity e has a component c in entity set E, and the parent of E in the tree is F, then entity e also has a component d in F. Further, c and d must be paired in the relationship set for the isa relationship from E to F. The entity e has whatever attributes any of its components has, and it participates in whatever relationships any of its components participate in.

Example (b) : The typical movie, being neither a cartoon nor a murder-mystery, will have a component only in the root entity set Movies in the following figure "Isa relationships in an E/R diagram". These entities have only the four attributes of Movies (and the two relationships of Movies - Stars-in and Owns - that are not shown in the following figure "Isa relationships in an E/R diagram").

A cartoon that is not a murder-mystery will have two components, one in Movies and one in Cartoons. Its entity will therefore have not only the four attributes of Movies, but the relationship Voices. Similarly, a murder-mystery will have two elements for its entity, one in Movies and one in Murder-Mysteries and in this way will have five attributes, including weapon.

Lastly, a movie like Roger Rabbit, which is both a cartoon and a murder-mystery, will have elements in all three of the entity sets Movies, Cartoons, and Murder-Mysteries. The three elements are connected into one entity by the isa relationships. Together, these elements give the Roger Rabbit entity all four attributes of Movies plus the attribute weapon of entity set Murder- Mysteries and the relationship Voices of entity set Cartoons.
Isa relationships in an E/R diagram

Parallel Relationships Can Be Different

The above figure "Replacing a multiway relationship by an entity set and binary relationships" demonstrates a subtle point about relationships. There are two different relationships, Studio-of-Star and Producing-Studio, that each connect entity sets Contracts and Studios. We should not assume that these relationships therefore have the same relationship sets. In reality, in this case, it is not likely that both relationships would ever relate the same contract to the same studios, since a studio would then be contracting with itself.
   
More normally, there is nothing wrong with an E/R diagram having some relationships that connect the same entity sets. In the database, the instances of these relationships will generally be different, reflecting the different meanings of the relationships. In reality, if the relationship sets for two relationships are expected to be the same, then they are really the same relationship and should not be given different names.



Tags