On Jun 11, 2008, at 3:06 PM, Bobby Impollonia wrote:

>
> Does SA support the following scenario? :
> I have a class (let's call in User). I have a many-to-many
> relationship between Users and urls where a url is just a string. So I
> want to have a secondary table where one column is a foreign key on
> User and the other is a string.

unless there's a third table involved, that sounds more like a one-to- 
many collection to me (user table->table of URLs).


> If the second column where a foreign key on a mapped table, I could
> use a relation so that for a given user I could append, remove, etc.
> the related items via an instrumented list. With them being raw
> strings instead of foreign keys on something else, is something like
> this still possible? Is there a way to say that I want an instrumented
> list of strings?

if you have a table of User id (FK) and URL string (FK), that's just a  
many-to-many table.  Set it as "secondary" in a relation() and you're  
good to go.   Strings can be foreign keys just like integers or most  
anything else.

If you want the collection to return strings directly and not mapped  
objects, the current approach for that is to use the associationproxy,  
detailed in the "plugins" chapter of the docs.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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