This is how I''d do it.... yachtman
Table locations { has_many :venues, has_many :contacts }
- id
- name
- address
- latitude
- longitude
Table contacts { belongs_to :location, has_many :contact_types }
- id
- name
- contact_type_id
- location_id
Table contact_types { belongs_to :contact }
- id
- type (owner or contact)
Table venues { belongs_to :location }
- id
- name
- location_id
Table events { belongs_to :venue }
- id
- name
- venue_id
- primary_contact_id
- owner_id
On Nov 20, 8:31 am, Cantankerous
<AlexElderfi...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:> I know this is an easy question for a software developer but I''m
new
> to this so I''d really appreciate a little help in designing
> associations. The basic models I have created are listed below but
I''m
> having a little trouble in linking the location (addresses)
> information to where it is needed in each of the other models. This is
> illustrated in two places:
>
> Linking events to a location
>
> My basic idea (from reading the various web posts - thanks) is that
> rather than using has_and_belongs_to_many I need to create another
> model called venues which links a location to an event, however all of
> the online examples seem to have a many-many relationship whereas I
> want to create a linking model where a location can have many venues
> (think the screens in a cinema) but an event can have only one venue.
> How to I write this?
>
> Contact details
>
> I then want to store two additional sets of contact details for each
> event, the primary contact (contact details public) and the event
> owner (private for admin use). Again, do I need to create some form of
> linking model (to store the type of contact) or can I just use habtm?
>
> Event_lists
> - Have a default venue (which has a location)
> - Have events (each has a location)
> - Has an owner (has an address - a location)
> - Has a primary contact (has an address - a location)
>
> Events
> - Have a venue (which has a location)
> - Have a primary contact (a person who has a location for this event)
> - Have an owner (a person who has a location)
>
> Location
> - Has an address
> - Has a latitude and longitude
>
> People
> - Have an address (which is a link to the location table)
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---