Thanks for the reply Joshua

On Jun 12, 8:21 pm, Joshua Benner <[EMAIL PROTECTED]> wrote:
> To, it sounds like:
>
> Person belongsTo Country
>
> I'd use a belongsTo relationship in the Person model.

Correct, this was a bad example, and in this case I'd tend to agree
and that type of relationship does work. Replacing "Country" with
"Thing", and considering that each person has a "Thing" is closer to
what I was thinking. "Things" know nothing about people, and are just
things. Each person will always have just one thing, so we don't need
the flexibility of a join table to associate an arbitrary number of
Things with a person.  A belongsTo relationship will do the job but
seems incorrect as in this case a Person has a Thing, and a Person
does not belong to a Thing. What is the case though is that the actual
value in the Thing column of a Person does belong to Things, and if we
consider that then it does make sense. So whilst Person as a whole
does not belong to Thing, the Thing *value* of a Person does belong to
Thing.

Another example would be Colour, where all manner of models might have
Colour as an attribute, but the models would not belong to colour.

> I wrote a bit on understanding the practical differences between
> relationships here:http://bennerweb.com/node/16

This is a great article, although you show why there is the confusion
when you write

"each movie has one director" but then model that relationship with
belongsTo and not hasOne :) Aside from the fact that belongsTo would
work and hasOne wouldn't, as a movie is the creative work of a
director it would be fair enough to consider that a movie belongs to a
director, but in some cases I feel that hasOne would be the clearer
and more natural choice as this is how we would explain the model to
someone.

It's evidently unnecessary for an enhancement to hasOne, however for
the sake of expressiveness, being able to use hasOne or perhaps an
"isA" concept might be clearer.

Thanks again for the helpful reply though.

Nick


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to