[sqlalchemy] Re: a-directional i.e. bi-directional m:m relations

2008-12-05 Thread Eric Ongerth

Thanks for the ideas.  I thought of all of the above.  The one I've
been using is the accessor which unions together the necessary
things.  My question came up when I wondered if there was some even
more fundamental way to handle these forwards-backwards cases.  I'm
glad to know I'm already doing all I can.


On Dec 2, 3:32 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Dec 2, 2008, at 5:54 PM, Eric Ongerth wrote:



  Now when I want to find out whether a Foo has a relation to another
  Foo, I have to check whether there exists any row in foo_relations
  that has the given Foo as either as this OR that.  Also, what if I
  need backrefs on the foo_relations mapper?  The backref from 'this'
  and the backref from 'that' would both point to something called a
  foo, but they would have to be given separate labels in order ot not
  be conflicting property names -- when really, I would not want to know
  if a foo was the 'that' or the 'this' of some foo relation.

  So ideally in a case like this, I could set an option that says the
  m:m relation is bidirectional, and that the backrefs for both foreign
  keys in the m:m table should really point to the same place (or at
  least be unioned together).

  I have a feeling that would violate some part of the RDBMS standards,
  and I'm perfectly willing to go without or work around.  This is more
  of a philosophical point for learning's sake -- what do other people
  do in such cases?

 you can store two rows in the association table, one for each  
 direction.   or provide an accessor which just unions together the  
 forwards and backwards references between Foo objects.  or make a  
 readonly relation() that does the appropriate OR logic.   I might  
 even try combining both of those techniques somehow.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: a-directional i.e. bi-directional m:m relations

2008-12-05 Thread az

there is... u do not want to know if A points B or B points A, u want 
to know if A and B are related in whatever aspect. That is, A and B 
are members of some set X denoting that aspect. i.e. moving the 
belonginess out of A and B alltogether.
but this isn't going to make your DB simpler... quite the opposite.

On Friday 05 December 2008 10:40:16 Eric Ongerth wrote:
 Thanks for the ideas.  I thought of all of the above.  The one I've
 been using is the accessor which unions together the necessary
 things.  My question came up when I wondered if there was some even
 more fundamental way to handle these forwards-backwards cases.  I'm
 glad to know I'm already doing all I can.

 On Dec 2, 3:32 pm, Michael Bayer [EMAIL PROTECTED] wrote:
  On Dec 2, 2008, at 5:54 PM, Eric Ongerth wrote:
   Now when I want to find out whether a Foo has a relation to
   another Foo, I have to check whether there exists any row in
   foo_relations that has the given Foo as either as this OR
   that.  Also, what if I need backrefs on the foo_relations
   mapper?  The backref from 'this' and the backref from 'that'
   would both point to something called a foo, but they would have
   to be given separate labels in order ot not be conflicting
   property names -- when really, I would not want to know if a
   foo was the 'that' or the 'this' of some foo relation.
  
   So ideally in a case like this, I could set an option that says
   the m:m relation is bidirectional, and that the backrefs for
   both foreign keys in the m:m table should really point to the
   same place (or at least be unioned together).
  
   I have a feeling that would violate some part of the RDBMS
   standards, and I'm perfectly willing to go without or work
   around.  This is more of a philosophical point for learning's
   sake -- what do other people do in such cases?
 
  you can store two rows in the association table, one for each
    direction.   or provide an accessor which just unions together
  the forwards and backwards references between Foo objects.  or
  make a readonly relation() that does the appropriate OR logic.
    I might even try combining both of those techniques somehow.

 


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



[sqlalchemy] Re: a-directional i.e. bi-directional m:m relations

2008-12-05 Thread Eric Ongerth

Oh, right.  I don't know what type of brain fog obscured that basic
relational fact, except that I may have been burning my synapses a bit
too hot lately resulting in a deplorable deficit of
neurotransmitters.  Thank you for helping me regain the sight of the
obvious.

On Dec 5, 1:16 am, [EMAIL PROTECTED] wrote:
 there is... u do not want to know if A points B or B points A, u want
 to know if A and B are related in whatever aspect. That is, A and B
 are members of some set X denoting that aspect. i.e. moving the
 belonginess out of A and B alltogether.
 but this isn't going to make your DB simpler... quite the opposite.

 On Friday 05 December 2008 10:40:16 Eric Ongerth wrote:

  Thanks for the ideas.  I thought of all of the above.  The one I've
  been using is the accessor which unions together the necessary
  things.  My question came up when I wondered if there was some even
  more fundamental way to handle these forwards-backwards cases.  I'm
  glad to know I'm already doing all I can.

  On Dec 2, 3:32 pm, Michael Bayer [EMAIL PROTECTED] wrote:
   On Dec 2, 2008, at 5:54 PM, Eric Ongerth wrote:
Now when I want to find out whether a Foo has a relation to
another Foo, I have to check whether there exists any row in
foo_relations that has the given Foo as either as this OR
that.  Also, what if I need backrefs on the foo_relations
mapper?  The backref from 'this' and the backref from 'that'
would both point to something called a foo, but they would have
to be given separate labels in order ot not be conflicting
property names -- when really, I would not want to know if a
foo was the 'that' or the 'this' of some foo relation.

So ideally in a case like this, I could set an option that says
the m:m relation is bidirectional, and that the backrefs for
both foreign keys in the m:m table should really point to the
same place (or at least be unioned together).

I have a feeling that would violate some part of the RDBMS
standards, and I'm perfectly willing to go without or work
around.  This is more of a philosophical point for learning's
sake -- what do other people do in such cases?

   you can store two rows in the association table, one for each
     direction.   or provide an accessor which just unions together
   the forwards and backwards references between Foo objects.  or
   make a readonly relation() that does the appropriate OR logic.
     I might even try combining both of those techniques somehow.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: a-directional i.e. bi-directional m:m relations

2008-12-02 Thread Michael Bayer


On Dec 2, 2008, at 5:54 PM, Eric Ongerth wrote:

 Now when I want to find out whether a Foo has a relation to another
 Foo, I have to check whether there exists any row in foo_relations
 that has the given Foo as either as this OR that.  Also, what if I
 need backrefs on the foo_relations mapper?  The backref from 'this'
 and the backref from 'that' would both point to something called a
 foo, but they would have to be given separate labels in order ot not
 be conflicting property names -- when really, I would not want to know
 if a foo was the 'that' or the 'this' of some foo relation.

 So ideally in a case like this, I could set an option that says the
 m:m relation is bidirectional, and that the backrefs for both foreign
 keys in the m:m table should really point to the same place (or at
 least be unioned together).

 I have a feeling that would violate some part of the RDBMS standards,
 and I'm perfectly willing to go without or work around.  This is more
 of a philosophical point for learning's sake -- what do other people
 do in such cases?

you can store two rows in the association table, one for each  
direction.   or provide an accessor which just unions together the  
forwards and backwards references between Foo objects.  or make a  
readonly relation() that does the appropriate OR logic.   I might  
even try combining both of those techniques somehow.


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