B.3: Supertypes, Subtypes and Attributes
All entity types including supertypes and subtypes can have attributes. Continuing with our library example suppose:
- all items have a call number and a title, and call number is a key (each item has a unique call number),
- videos have a duration (time required to play),
- books have a length (number of pages).
Just as subtypes inherit relationships, they also inherit any attributes of their supertype, and we also have that supertypes do not inherit the attributes of their subtypes. Attributes that are common to a supertype and its subtypes are only shown at the supertype.
Consider our model now:
Our examples have been two-level hierarchies. In general, a hierarchy can be as many levels as the designer requires. For instance, books could be categorized as fiction and non-fiction and so book can be a subtype of item and at the same time a supertype of fiction and non-fiction.