On Sun, 2003-06-01 at 01:46, Edmund Lian wrote:
> Now the problem is that relationships have attributes too. For example,
> we might want to store the date relationship started, intensity, etc.
> These are attributes of the relationship, not of Person or Dog.
>
> In traditional schema, this would be stored in the mapping table, or
> some table that is related to the mapping table. How do we deal with
> this in SQLObject?
It looks like you got this resolved, and that's probably the right
resolution as well. After the next release I'm going to beef up the
join stuff a bit more, and it will be possible to add extra values to
the join. So you might do (in my as-yet-imaginary extension):
class Person(SQLObject):
dogs = ExtensibleRelatedJoin('Dog', extraColumn='times_per_day')
class Dog(SQLObject):
people = ExtensibleRelatedJoin('Person',
extraColumn='times_per_day')
d = Dog.new()
p = Person.new()
d.addPerson(p, 1) # p walks d once per day
p2 = Person.new()
d.addPerson(p2, 3) # p2 walks d three times per day (lots of walking)
d.people
>>> [(<Person 1>, 1), (<Person 2>, 3)]
p.dogs
>>> [(<Dog 1>, 1)]
If the relationship starts getting more complicted, than full SQLObject
classes for the relation table are probably called for.
Ian
|