On Wed, Oct 24, 2012 at 2:56 PM, Kevin McCaughey <li...@ruby-forum.com> wrote:

> Thanks Dave - I have put the new diagram up at:
> http://www.kevinmccaughey.org/relationships/relationships.html

That doesn't show me something new.  Maybe there's something caching
it too much.  However:

> Attachments:
> http://www.ruby-forum.com/attachment/7828/Base_Classes.jpg

That shows me a new diagram.  It's almost what I meant, but you've got
Bookings having many Rooms, whereas I was thinking they would *belong
to* Rooms.  (And you've got Meetings having *one* Booking, whereas I
was thinking they'd have many.)  Bookings would be essentially nothing
but a join table between Meetings and Rooms, just like Attendances is
between Meetings and People.  Just like a Person can have many
Meetings and vice-versa, through many Attendances, each of which
belongs to one of the other model, a Meeting can have many Rooms and
vice-versa, through many Bookings, each of which belongs to one of the
other model.

In diagrammatic terms, diamondize the Booking end of the link from
Meeting, and reverse the one from Room.  Like this (words chopped to
make the whole thing fit on one line, and adopting the User
suggestion):

User ()-<> Attend <>-() Mtg ()-<> Bookg <>-() Rm <>-() Bldg

Or, to de-UMLify it:

User  1-*  Attend  *-1  Mtg  1-*  Bookg  *-1  Rm  *-1 Bldg

BTW, one of the things that I find confuses new Rails people about the
difference between "has" and "belongs_to", is which model has to store
the ID of the other model (as a foreign key).  They way I usually
remember it is that if something belongs to me, it might have my name
written on it, but I'm certainly not going to have the "names" of
everything that belongs to me, written on me.  So in Rails, if model
Dog has_many legs, the legs table has a dog_id column.  (Or if you've
got dog legs and cat legs and so on all mixed up in one table, you can
tell Rails the column name is owner_id or something like that.)

-Dave

-- 
Dave Aronson, the T. Rex of Codosaurus LLC,
secret-cleared freelance software developer
taking contracts in or near NoVa or remote.
See information at http://www.Codosaur.us/.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to