Relationship Manager Page 12 21/08/01
relational database designers face when optimising their query engines.
An Object-oriented database management system (ODBMS) treats objects as first class
citizens, storing objects not tables. ODBMS queries return lists of objects - not table
recordsets. Relationship Manager is like an ODBMS, in that they both store relationships
between objects. However Relationship Manager doesn’t require that you store the objects
themselves, like an ODBMS does. ODBMS systems also offer a range of transaction control
and robustness functionality that pure Relationship Manager does not. You could certainly
implement Relationship Manager using an OODBMS, and Relationship Manager could
certainly benefit from the speed and robustness features of an OODBMS.
The Relationship Object and the Collection Object (Noble PLOPD4, “Basic Relationship
Patterns”, p 80) use an instance of each type for each relationship or for each one-to-many
relationship respectively. The solution of Relationship Manager goes further and models all
(or many) relationships in one central Relationship Manager. Whilst both patterns intend to
help ease implementation of relationships between classes there are several differences in
intent, forces and implementation:
Relationship Manager Relationship Object
Intent: Intent is to provide a global dictionary
of relationship mappings between all or many
classes
Intent is to represent a single, possibly
complex and constrained relationship
involving two or more classes
Interface: Interface to a Relationship Manager
is generic – simply a pair of add/remove
relationship methods and a single query method
which returns a list of objects e.g.
FindObjects(from, to, relId) : TList
Interface for a Relationship Object is
flexible, and depends on the situation and
the classes involved. Method names might
be customised to suit the context.
Note that Collection Objects (which are
Relationship Objects) typically will have
similar interfaces e.g. Java vector, Delphi
TList all have similar methods relating to
add/remove/find/indexing/pack/sort etc.
Scope of implementation: No complexity
encapsulated by a Relationship Manager. No
‘relationship constraints’ are maintained or
enforced. It just stores mapping pairs and
responds to generic queries
Encapsulates complexity – one of the intents
of Relationship Object is to encapsulate the
rules and constraints of a possibly complex
relationship amongst two or more classes
Cardinality: One Relationship Manager for all
relationships. Usually a global singleton offering
generic mapping services.
Note: Multiple RMs can be used to service
different varieties of classes, if there are
efficiency or conceptual separation concerns.
One Relationship Object per relationship: A
Relationship Object needs to be created for
each relationship (that you want to represent
in this way). Each Relationship Object is
usually owned by the class it is serving.
Alternatively the interface of the
Relationship Object may be merged with an
existing business class interface.
Note: Relationship Object and Relationship Manager can complement each other, working
together when complex relationship constraints need to be implemented. The Relationship