Craig Miskell wrote:
>>
>>Database having a "one to many" while object model is "one-to-one" is such
>>a scenario. This is a valid and quiet common (though not the best) way of
>>handling "master-detail" modeling in the db.
>>
> Just to clarify the situation when it would be used: Is
> this where although the db would technically allow multiple destination
> rows (because the attributes aren't the pk, just an fk back to the
> source), but in practice there will only ever be one matching row?
Yes, this is it.
> Regardless of whether we support it now, if it's something that should
> probably be supported in future, then it kind of scuttles my plan :-(.
> I still think it's valid to calculate the nature of the toMany status
> for flattened relationships though... unless of course it'd be valid to
> flatten across one of these interesting master-detail relationships...
> urgh.. Andrus... what are you really saying?
I was just trying to come up with possible scenarios. Now that you
mentioned future plans, this got me really thinking. Here is what I got.
There are two logically independent definitions of cardinality for
ObjRelationships:
1. The one derived from the database constraints (and thus -
DbRelationships)
2. One derived from the object model, meaning that destination object is
either "just an object" or a collection.
Given that in most cases (1) and (2) will be the same, this distinction
is rather academic, and we ignored it till now. The only case I can
think of when (1) and (2) are different is the one we discussed above.
Following this logic, Cayenne currently does not care or support (2),
and (1) can (and should) be derived. So you were right, we can make it
easy for users and always derive cardinality from Db.
+1 for that.
If we ever need to address (2) explicitly, we may come up with a
separate property for it.
So yeah, I guess we can move "toMany" from Relationship superclass into
DbRelationship.
Andrus
This archive was generated by hypermail 2.0.0 : Tue Mar 04 2003 - 21:30:19 EST