On 7/4/07, psnively <[EMAIL PROTECTED]> wrote:
>
> > Apart for an existing DB where a specific table handles this one-to-one
> > relation, what is the benefit of this method over the
> > belongs_to / has_one syntax ? You also get a bidirectional association,
> > don't you ?
>
> You do, but it's strictly 1-1 or 1-N (in whatever direction). In other
> words, when you change the reference on either end, you... change the
> reference. With has_and_belongs_to(uselist=False), you get
> bidirectional (a named attribute on both models), 1-1 (each reference
> is singular), but each entity can have a distinct reference to some
> other distinct entity--that is, under the hood, an association table
> is still created, and the foreign key references on the entities
> actually refer to that association table, which in turn refers to the
> other entity.
You seem to be confused by what an has_and_belongs_to_many does. There
are no foreign key from the entities to the association table. Only
from the association table to both entities!

> This prevents weird semantics (from the object-oriented
> perspective), where an entity can only be associated with a single
> other entity, and "vanishes" from the entity it was previously
> associated with when the reference on the parent entity is changed.

This also happens when using has_and_belongs_to_one (or whatever you
call it). So, I really don't see the point in your change, except to
support a database doing it this way already (as noted by Remi), and
this seem rare enough to stay out of the main distribution.

-- 
Gaƫtan de Menten
http://openhex.org

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

Reply via email to