Re: Modeling complex associations

Till
Mon, 19 Jan 2009 14:15:13 -0000

Thanks very much for the hint - I didn''t think of that problem.

> - you could create a polymorphic building with an interface for
> headquarter and branch

I think it''s a good idea to differentiate headquarters and building
using another model (did I get this right?)
Would you suggest - assuming that building belongs_to company in a
polymorphic way - to create a table for headquarters? As it''s just a
unique property among the set of buildings belonging to one company
maybe it''s good to use STI and let Headquarter inherit from Building.
In the database this would result in a kind of flag (the type column)
as well, but maybe it would cause more readable code and prevent some
"if building.headquarter" patterns.