[Catalyst] Re: Adding relationships to loaded CDBI models
samwyse at gmail.com
Wed Jun 22 07:13:09 CEST 2005
On 6/21/05, James Tolley <james.tolley at gmail.com> wrote:
> > '(0..1)' and '(0..n)' are trickier. If object A (employee) has a
> > reference to object B (spouse), and that reference can be NULL, then
> > each person "might have" a spouse. That seems to cover the '(0..1)'
> > case. '(0..n)' is generalization of the '(1..n)' case, wherein a
> > brewery doesn't produce any beer; it gets lumped in with 'has_many'
> > and we hope that there's no need to differentiate.
> I'm not sure that you're getting to the heart of it. has_a and
> has_many are great, but there are other relationships supported by
> Class::DBI which are not covered by CDBI::Loader. Why not cover
> everything possible? I'm sure that even the marginal case of
> might_have will be very useful to many people if implemented.
I suspect that you mean "if *properly* implemented". I don't see a
difference between your method of deciding "might_have" and the method
already used for "has_a". For this reason alone, I'd just as soon
leave "might_have" non-automatic.
CDBI::Loader tries to make life easier by picking up common
relationships whose existance can be infered from the meta-data
already stored in a schema. Those are, IMHO, pretty much limited to
'has_a' and 'has_many'. 'might_have' is harder to figure out, since
the words "might have" imply "might not have", which contradicts the
seemingly definitness of "has a".
There's a difficulty here, which I freely admit, that the semantics of
the formal relationships "has_a" and "has_many" may or may not
correspond to the semantics of the English phrases "has a" and "has
many". This can lead to confusion of the sort where "we" means both
"me and you" and "me and them"; the confusion compounds when one
realizes that "you" can mean either "yourself" or "yourself and
themselves". I see five ways to classify simple relationships,
without getting into things like "is a", "variant of" or "has many
sorted", and how "has_a" and "has_many" maps into those five is a bit
More information about the Catalyst