On 16 Jun 2005, olivier hericord <hangonsoft-GANU6spQydw@public.gmane.org>
wrote :
> i love rails but this single page make me think that the STI choice
> leads to weird things ... oop with ruby is beauty and sti breaks this
> beauty...
>
> http://developer.apple.com/documentation/WebObjects/UsingEOModeler/
> 7ModelingInheritance/chapter_7_section_2.html#//apple_ref/doc/uid/
> TP30001018-DontLinkChapterID_6-CACFDHEB
>
STI is a bit of a pig in certain cases, but it''s generally easy
enough to work around. The easiest is to wrap all the attributes in
one table, which is of course utterly foul and disgusting. An
alternative is to have, for the following hierarchy (note the
creative use of ascii), tables "foos", "bar1_details" and
"bar2_details"
foo <- bar1
^
+- bar2
thus, the ''foos'' table _only_ has relationships and attributes
for
the base class, and the ..._details tables deal with the subclass
attributes. Then use eager loading on the subclasses to get the
details, and pass unrecognised selectors on to the _details subclasses
The only pain here is that you end up with 5 classes where 3 should
have sufficed, but even that could probably be got around with a
little creative thinking - you can certainly keep the bar1 and
bar1_details classes in the same file, so at least it''s all in the
same place.
That is _one_ possible solution to multiple table inheritance, there
are others.
Simon