something. Within a database or file, it is important that each
object represented has a unique surrogate that is not used for
anything else so that information about the object can be
grouped together. In a database, this might be provided by a
column derived from an attribute.
If you use a relationship type as part of the internal identi-
fier, this makes recording the existe nce of the object depen-
dent on the rela tionship type, and hence it makes existence of
information about t he object dependent on knowing informa-
tion about the objec t it is related to. This can lead to pro-
blems, because e ven if there is a real-world dependence, it
does not necessarily translate into da ta dependence. For
example, jus t because I must have two parents does not mean
that you must know who my parents are to know me. In any
case, if your data model has a comp lete subtype/supertype
hier archy, your identification will be inherited from the thing
entity type, or whatever you have called your supreme super-
type, and no relationship types at that level could be part of
the identifier for all its subtypes. It is always possi ble to have
alternativ e unique identifiers based on combinations of rela-
tionship types.
Another problem that can arise is when the relationship
types may be necessa ry dependencies, but together they may
not form a unique key. An example of this can be with an inter-
section entity type resolving a many-to-many relationship type,
when the same relationship type can occur between two objects
on more than one occasion. The combination of foreign keys is
not sufficient for a unique identifier.
So it is prudent to provide objects with an identifier attribute
as the primary key so that you are not a hostage to fortune.
This has the advantage of always working and giving a level of
consistency to your data model.
7.2.2 An Example of Inappropriate Choice of
Unique Identifier—Ship
In the real world things don’t necessarily come with a
convenient number stamped on them for identification.
Somet imes we have to give things an identifier, and o ften
we refer to things indirectly— “the one I ordered last week”—
and rely on the context. It is tempti ng to ca rry over this
indi rect ide ntification of objects through the relationships or
attributes they have and into data models where it can cause
problems.
Chapter 7 APPLYING THE PRINCIPLES FOR ATTRIBUTES 85