What I need to know is how to model a self-referencing relationship
using SQLObject.
Why? Let's say I want to model a father-son relationship. So I would
have a table in the database containing person data. Two of the
atributes of that table should be father and mother, that should
reference another record of the same table.
How to I model that with SQLObject.
Thanx in advance.
Marcos
class Person(SQLObject):
name = StringCol(alternateID=True, length=30)
child = RelatedJoin('People',intermediateTable='peopleparentchild',
joinColumn='parent',otherColumn='child')
Assign like this like this:
john = Person(name='john')
chris = Person(name='chris')
christina = Person(name='christina')
paul = Person(name='paul')
paula = Person(name='paula')
# Make chris and christina children of john
john.addPerson(chris)
john.addPerson(christina)
# Make paul and paul parents of john
paul.addPerson(name='john')
paula.addPerson(name='john')
Thanks
child = RelatedJoin('Person',intermediateTable='peopleparentchild',
joinColumn='parent',otherColumn='child') ?