Subtyping

The last concept we need is that of subtype. When you say that entity type A is a subtype of B, or, more informally, that "A is a B", you are saying that all attributes of B are also attributes of A, and all relationship types incident to B are also incident on A (this phenomenon is usually called "subclassing" or "inheritance" in object-oriented jargon). In our example, subscriber is a subtype of person: indeed, each subscriber has a name, but has also other information.

ERW supports subtyping. For each entity type, you can specify, using the isa element, any number of supertypes, whose attributes and incident relationship types will be inherited (this is called multiple inheritance in object-oriented jargon). Obviously, you cannot form cycles (ERtool will prevent you from doing this).

Semantically, subtyping is modelled by set inclusion. That is, if A is a B then in every schema instance the set associated to A is a subset of the one associated to B. That is, every entity of type A is also an entity of type B.

To be completely precise, ERW adopts a restriction on the allowable assignments of sets to entity types: it is required that every entity has a definite type. For instance, if A and B are both a C, then it is not possible that an entity is in both A, B and C unless it is also in a common subtype of A and B. This avoids, for instance, that if man and woman are subtypes of person you can have an entity that is both a man and a woman (but should you need that, you just have to add a suitable subtype hermaphrodite of both man and woman).

Finally, ERW lets you mark an entity type A as abstract. In this case, there can be no entity whose type is A, but it is possible that there are entities whose type is a subtype of A. Of course, abstract types without subtypes are completely useless. But, should you need every person to be either a man or a woman (or possibly a hermaphrodite), you can declare person as abstract. Mathematically, the set of entities associated to an abstract entity type must coincide with the union of the sets associated to its proper subtypes.