On 2005-11-02 09:27:11 -0800, [EMAIL PROTECTED] wrote:
> 
> I am confused again. How would you design this :
> 
> Invoice <--> Payment
> 
> where each invoice can have multiple payments and each payment can pay
> multiple invoice. Isn't it natural to have a tuple (invoice, payment,
> amount) which is a join and also have attribute that is essential ?

i'm not sure i understand your example. what would the underlying
database tables look like?

what i'm saying is that if you have a table like

  foobar
  ------------
  foo_id
  bar_id

then SQLObject handles that just fine with

  class Foo(SQLObject):
       bars = RelatedJoin('Bar')

  class Bar(SQLObject):
       foos = RelatedJoin('Foo')

but if you want the join table to look like:

  foobar
  ----------
  foo_id
  bar_id
  some_other_field

you should use something more like:

  class Foo(SQLObject):
      bars = MultipleJoin('FooBar')
    
  class Bar(SQLObject):
      foos = MultipleJoin('FooBar')

  class FooBar(SQLObject):
      foo = ForeignKey('Foo')
      bar = ForeignKey('Bar')
      some_other_field = StringCol()

-- 
anders pearson : http://www.columbia.edu/~anders/
   C C N M T L : http://www.ccnmtl.columbia.edu/
        weblog : http://thraxil.org/

Attachment: pgpVu7AG04wgY.pgp
Description: PGP signature

Reply via email to