|
Using Current Relational Databases
The previous section assumed we could modify the relational model to add features we need for object-relational mapping. In the long run this may be possible but currently it is not. Current relational systems do not support objects with identity as the values of tuple attributes. Most relational systems do not support anything more than basic data types as tuple attributes. Have we returned to the impedance mismatch? No, we already have an approach that is a good integration of Relational and Object models. We only need to implement it with current technology.
IdentityKeys: Relinquishing Objects for ObjectShadows
We can not directly store objects with identity in current relational databases. Instead we will just store an IdentityKey as an ObjectShadow: the existence of an IdentityKey indicates that an Object exists but that the database can not directly represent the actual object. We only have the shadow of the object, which is less convenient to work with but contains as much information.
Distinguishers: Identifying an Objects Type
In the above example the type of the ObjectShadow is obvious. It is always a person for the ID column and it is always a company for the Company_ID column. What if we allow the type of a domain to vary over multiple classes? How do we identify what type of object that shadow is for? We need some manner to first identify the objects class and then use the objects IdentityKey to identify the object within that class. We need a more knowledgeable shadow.
We can add this knowledge through a distinguisher that identifies which class of object the shadow is for. We first find the class through the distinguisher and then find the object of that class through the identityKey.
Summary
Working with current relational technology makes implementing objects in the database much more cumbersome, but the model is still valid and possible. Instead of having real objects we have object shadows which indicates the existence of a particular object. Object shadows can either be simply IdentityKeys for a single type domain or IdentityKey plus a distinguisher if the domain could be multiple types. In all cases the ObjectShadow must be sufficient to uniquely identify the single true object that should be in its place. If we have this we have objects.
|