On Oct 26, 2010, at 7:21 AM, Adam Medveczky wrote:

> Hi!
> 
> I have a localization table, with a string_id, locale_id which make a
> composite key (and of course the localized string)
> 
> I'd like to refer to it from various tables, based on a local field
> which resembles 'string_id'.
> 
> If I wanted to do this with only one table referring to it, it would
> be a simple one-to-many association, but now I'd have to put a foreign
> key of each referral table (having always one filled), which may be a
> solution, but certainly not the best.

If this were simple many-to-one, i.e. A.string_id (fk) -> 
localization.string_id, B.string_id (fk) -> localization.string_id, etc.  , 
that's very simple, but I guess you're looking for a collection.


> Making an intermediate associate
> table suffers the same drawback, still more keys are needed.

so this sounds more like yes you're looking for a collection:

A -> a_to_locale.string_id (fk) -> localization.string_id, B -> 
b_to_locale.string_id (fk) -> localization.string_id .    This is actually the 
solution I recommend in my old blog post about polymorphic associations 
http://techspot.zzzeek.org/?p=13 .

There's no real "drawback" to having lots of foreign keys.   Relational 
structures can be verbose but thats why tools like SQLAlchemy were created.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to