There is definitely support for one-to-one relationships. Check Doug's
excellent documentation included in the download -- page 46 has some
examples of using <hasOne...> connections. Basically it works just like
you've suggested but check the samples.
brian
David A. Cheslow PhD wrote:
Hi again;
Still loving reactor Doug! Keep up the great work!
Support for Many-to-Many and One-to-Many relations seems pretty
complete... noticeably missing is support for One-to-One relations.
Only one of the tables involved in a one-to-one relation needs to
contain a foreign key to the other table. Relational algebra does
not help us choose which table gets the extra field, but domain
knowledge usually makes it obvious. Adding a "back pointer foreign
key" from the other table creates ugly problems with cascades and
creates a lot of unnecessary work. Knowing that the relation is
one-to-one allows the "back reference" to be calculated... just as it
is for the "many" side of a one-to-many relation.
Let's say that 'Person' as a one-to-one relation with 'Address'. We
store a foreign key to the Address table in the Person table (we could
just as easily store a foreign key to Person in Address... but that
makes less sense, for some reason). Reactor allows us to call
getAddressRecord() on a PersonRecord... but it does not allow us to
call getPersonRecord() on an AddressRecord, even though all the needed
information is available.
Syntactically, this could be supported the same way that it is for
Many-to-Many relationships. For example, something like:
<object name="person">
<hasOne name="address" alias="homeaddress">
<relate from="homeaddressId" to="addressId" />
</hasOne>
</object>
<object name="address">
<hasOne name="person" alias="whereILive">
<link name="person" from="addressid"
to="homeaddressid" />
</hasOne>
</object>
There are two patterns in which I frequently use one-to-one relations:
when a sub-element repeats in an object (e.g. person has-one
'homeaddress' AND person has-one 'workaddress') and for storing object
hierarchies in a RDB (each instance has a one-to-one relation with an
instance of it's superclass).
Adding this functionality outside of reactor is trivial, but it would
also be trivial to add it into reactor...
Just food for thought, love the reactor,
=dave=
-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/
-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/