Re: Modeling complex associations

David Medinets
Mon, 19 Jan 2009 15:10:25 -0000

I agree with Ar that you simply need a join table to hold the
relationship from the Company to its Headquarters instead of using an
object hierarchy and inheritance. Using Modules to insert and

class Company
  company_id
end

class Building
  building_id
end

class CompanyHeadquarters
  company_id
  building_id
end

Having the CompanyHeadquarters object may come in handy if you need
extra information about the Headquarters building that is different
from a normal building.

On Jan 19, 9:44 am, Ar Chron
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
> > I think it''s a good idea to differentiate headquarters and
building
> > using another model (did I get this right?)

> That depends... is there something substantively different about a
> building that is designated as the headquarters? I.e., are you
> maintaining additional data that is specific to a "headquarters"?
>
> So if companies can have space in multiple buildings, and a single
> building can house space for multiple companies, you need a join table
> that represents company-building combinations (officespaces?), and it
> seems that this join entity is what you would need to designate as a
> headquarters or not.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com