[storm] Many-to-many with join data

Matt Haggard haggardii at gmail.com
Fri Oct 29 22:49:23 BST 2010


I have three tables:

Company { id, name }
CompanyModelJoin { id, company_id, model_id, tag }
Model { id, name }

CompanyModelJoin is the many-to-many join table.

So, a company can have multiple models and a model can be used by
multiple companies.  But there's that tag field in the join table.  I
want somehow to do:

>>> print '\n'.join(['%r, %r' %x for x in company.models])
'tag-foo', <Model object A>
'tag-bar', <Model object B>
'another tag', <Model object A>

============================================================================
The Question

How would I construct the .models attribute on the Company class to do
something like that?  Or should I just make custom getter/setter
functions?
============================================================================

If this is too much of database-design question and not specific to
storm, I can ask elsewhere.

Thanks,

Matt



More information about the storm mailing list