Hi,

I have a complex system, but what I want to achieve is similair to the 
following:


I have a few type of adresses (have two as an example, should have many more):


class StreetAddress(Base):
        __tablename__                   =       "streetaddress"
        Type                                    = Column
        Id                                              = Column(Integer, 
primary_key=True)
        Street                                  = Column(Unicode(100))
        Number                                  = Column(Unicode(10))
        Zip                                             = Column(Unicode(10))
        ......



class WebAddress(Base):
        __tablename__                   = "webaddress"
        Id                                              = Column(Integer, 
primary_key=True)
        Type                                    = Column(Unicode(20))
        Url                                             = Column(Unicode(255))



Now I want to have a "Person" class, which can have multiple addresses:


class Person(Base):
        __tablename__                   = "person"
        Id                                              = Column(Integer, 
primary_key=True)
        FirstName                               = Column(Unicode(100))
        LastName                                = Column(Unicode(100))
        Addresses                               = .................


the Adresses field could be a "StreetAdress", "WebAddress", "Email-Address" 
etc, etc. 
Trouble is, that there there are "Affiliations" like companies which should be 
able to have addresses and webaddresses to, all with "backrefs" and cascading 
deletes.

I think I need a "Table" in the middle but I am not sure on how to make this 
work nicely

I might want to do something like this:

in the Person Class define a relation to a "man in the middle table"

class Addresses(Base):
        __tablename__   = "Addresses"
        Id                              = Column(Integer, primary_key=True)

        Type                    = Column(Unicode(20))   # Define the "relation" 
by storing the tablename like "streetaddress" or "webaddress"



Any suggestions?

Martijn
        








-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en.

Reply via email to