>sounds to me you need inheritance, the problem being that relational db's
>know nada about oo... right?
right

>then have a finder method that looks up the animal by pk, gets the
>category name (which will be something like 'dog', 'fish') and uses that
>to construct a query on the table with the same name.
>so in 'category', 'name' will be the reference to what table to do the
>real lookup in, then use that table's animal_fk.
>obviously you'll have to create an 'animal' row for each 'dog' etc.
>and for full inheritance mapped to the db there'd also be a 'canine',
>'mammal'... be pretty hard to do do with bmp..!

You correctly describe the desired behaviour but I am not sure about
precomputation and explicit storage of implied inherited classifications;
this would introduce horrific opportunity for update anomalies.

>if your dba needs to be able to verify referential integrity (why?) they
>won't like you doing this - don't think you can write a lookup like that
>in pure ANSI sql! :>

Correct, you can't. It is specifically NOT supported.

>i'd probably have create-methods on the animal/dog etc beans that take a
>Category arg and a pk, to make the finder neater. or use a Factory
>pattern.

>advantage -> a very flexible data structure, and that lookups will always
>be on pk (no more lookups than the object has parent categories).

I have written a helper class to expand the set of explicit classifications
to include all the classifications implied by inheritance. I am hoping that
this will be enough to simplify finder methods.

The only case I foresee in which it will be desirable to have fully
"flattened" classification (so that SQL can do all the manipulation and
transformation) is for reporting. For such cases - batch style tasks that
process *all* the data - I see no problem with preprocessing the
implications of THINGCATEGORY into a FLATTHINGCATEGORY table.

As you can probably tell I'm starting to make some headway.

Peter Routtier-Wone
---------------------------------------
One day, all this too shall parse.



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to