> 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!
Yes, I misspoke in the paragraph that you quoted. Thanks! > > 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). I can prove, by demonstration, that this isn't the case, and the reason why should be immediately apparent: with has_one/belongs_to, the association is 1-1 and there is no association table, so the entity with the "belongs_to" really can only belong to one other entity at a time. By contrast, a "has_and_belongs_to_one" or "has_and_belongs_to" with uselist=False continues to build an association table, so the association is N-N, but each individual entity is understood to refer to only one of the other entities. But because the relationship is N-N under the covers, each entity can belong to many entities at the other end of the association. That is the sole difference. > 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. The point is to correctly support bidirectional 1-1 associations, which are not the same, semantically, as unidirectional 1-1 associations, as my changes to Elixir demonstrate in practice. > -- > Gaƫtan de Mentenhttp://openhex.org Best regards, Paul Snively --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
