Newsgroups: comp.object,comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!gatech!newsfeed.pitt.edu!uunet!rcm!rmartin
From: rmartin@rcmcon.com (Robert Martin)
Subject: Re: OO to RDBMS Access
References: <3dut9e$slo@redstone.interpath.net>
Organization: R. C. M. Consulting Inc. 708-918-1004
Date: Fri, 6 Jan 1995 18:48:45 GMT
Message-ID: <1995Jan6.184845.13171@rcmcon.com>
Lines: 45
Xref: glinda.oz.cs.cmu.edu comp.object:24715 comp.lang.smalltalk:19275

ron@rschultz.pdial.interpath.net writes:


>Does anyone have any specific examples, frameworks, tips and
>techniques, for  mapping objects to relational databases other than
>the "an object = a row"  nonsense. We are attempting to develop a
>generic framework for Smalltalk access  to RDBMS and would like to
>share thoughts and ideas with others regarding our  approach. In
>particular, we are looking for minimizing the degree of coupling 
>between our domain objects and their persistence mechanisms, as well
>as  allowing support for objects containing collections in
>databases such as  Oracle. Any references, tool pointers, and
>support would be appreciated.

I use a surrogation method.  

Consider that class A uses class B.   It turns out that B is
persistent, and in an RDBMS, but I don't want A to know about the
RDBMS.  I create an abstract version of B (B') whose methods are all pure.
I then create two derivatives: the orignial B, and a B surrogate (Bs).

Bs knows about the RDBMS, it also knows what queries to use to access
B objects. 

Now, A objects want to send x messages to B objects.  However the A
objects are handed Bs objects instead of B objects.  This does not
matter because all the A objects are expecting are objects that
conform to the B' interface.

The Bs object catches the 'x' message, Makes the necessary queries,
constructs a B object, and then forwards the 'x' message.  Voila!

The surrogates can be as simple or as complex as you like.  They can
cache the objects, deal with locking and transaction boundaries, etc.
Yet, neither A nor B know anything at all about the RDBMS.  

My recent book has a chapter named "Paradigm Crossings" which
discusses this topic in much more detail.


-- 
Robert Martin       | Design Consulting   | Training courses offered:
Object Mentor Assoc.| rmartin@rcmcon.com  |   Object Oriented Analysis
2080 Cranbrook Rd.  | Tel: (708) 918-1004 |   Object Oriented Design
Green Oaks IL 60048 | Fax: (708) 918-1023 |   C++
