I just put up a pastebin for someone yesterday with that identical  
structure, its here:

http://paste.turbogears.org/paste/1975


On Feb 12, 2008, at 3:14 PM, Chris wrote:

>
> I'm having a bit of difficulty figuring out how to map 3 of my tables.
>
> ::Roles::
> id
> role
>
> ::Orgs::
> id
> name
>
> ::Users::
> id
> username
>
> ::Users_Roles_Orgs::
> id
> user_id
> org_id
> role_id
>
> Users_Roles_Orgs is the many to many join for Users and Orgs but I
> also need to know what roles the user has in that org, hence the
> role_id FK.  But, I do not know how to handle the third foreign key
> role_id in the mapping.  It is somewhat like the association mapper
> example in the docs, except it is a foreign key and not just data.
>
> Ultimately, I want to be able to do something like:
> # Get a user's roles for a specific org
> some_user.get_roles(some_org)
> # Or maybe
> Roles.filter_by(org=some_org, user=some_user)
>
>
> First, is there a better way to structure this relationship?  If not,
> I'd
> grateful for any tips on how to map the tables to object that will
> allow easy
> access to the data because I'm stuck.
> Thanks.
> >


--~--~---------~--~----~------------~-------~--~----~
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