The advantages of
using subtypes and supertypes are as follows:
·
|
First of all it allows you to make your table structure the
exact image of your data model. You do not need to cut up parts of
your data model and define very similar tables for them. |
·
|
Secondly, defining subtypes and supertypes builds many implicit
rules into the application, which are checked automatically. This
means that there is no need to write constraints that enforce these
rules and therefore that less constraints (and thus SQL statements)
need to be written. Maintenance costs will also be much lower. |
·
|
Thirdly, the windows that are generated by default will better
suit the end-users' needs. By default, USoft Developer generates a
separate window for every database object, whether it is a
supertype or a subtype. The window in which a supertype is shown
indicates what subtypes exist for the particular instance of the
supertype. As the windows only contain fields that have been
defined for a particular table (subtype or supertype), users do not
have to tab through fields that are irrelevant for some of the
subtypes. |
·
|
Finally, defining supertypes and subtypes enables you to reuse
object definitions at different levels. It is important to choose
the common core of attributes (the supertype), and the variable
additions (subtypes) in such a manner that they can be used for
more than one purpose. In the example shown above, the Person
supertype is divided into the Sales, Guide and Staff subtypes.
Should later applications also require Person subtypes, then the
existing subtype definitions can be reused, and only an
Administration subtype (for example) needs to be defined. |
A supertype always has one or
more subtypes. A subtype itself can be the supertype of other
subtypes, so the Guide subtype could itself have subtypes such as
Trainee and Experienced. Where a subtype is a supertype of other
subtypes, all the subtypes from a particular supertype downwards in
the subtype tree is known as a "constellation".
Subtype tree and constellations
|