On Wed, Oct 24, 2012 at 1:00 PM, Kevin McCaughey <li...@ruby-forum.com> wrote:
> As for the Bookings table, the reasoning behind this is in case there > are multiple meetings going on in the same building, at the same time - > there needs to be a way to differentiate them. If I simply use a room > number, then we still have the issue of a many to many for > Meeting<->Place. So, I thought that rather than just do a straight join > table, I could logically separate the meetings into "bookings" (if that > makes sense). > > I am looking at all this from the staff point of view - I want staff > (Person) to be able to fill in a time-table for their weeks and someone > else be able to view meetings happening (i.e. a manager has a look at > what his staff are doing for the week, can look at any one member of > staff at a given point of time to see where they should be, are they > safe etc). > > As for keeping track of the rooms, I am not too worried about that. Hmmmm. I'm thinking that in order to minimize conflicts due to typos (someone books the Smythe room, but the next clerk doesn't know it's spelled that way, and books the Smith room), and simplify the Bookings stuff, I'd probably: - Move the time to the Meeting, with starts_at and ends_at times. - Make a Room model, with at least the name, even if you don't need to track the floor, size, capacity, etc. At the very least, it could be useful to populate dropdowns or do autocompletion. This would belong_to Place, which I'd probably rename to Building since that seems to be the level of granularity. - Slightly repurpose Booking to be a join table between Meeting and Room, so that a Meeting could be held in several Rooms (as often happens at hotels for conventions that need various sized rooms), and a Room could of course be used for many Meetings. (One could argue that you don't need an explicitly named join table for this, and can just use a "has_and_belongs_to_many" (HABTM) relationship. However, I've heard many people say that it's a royal pain to retrofit that to a "has many :through" (HMT) relationship when you find you need to actually put data on the relationship, so I tend to start with HABTM in the first place.) So, in order to find what Meetings all a Place's Rooms will be used for, today, you just say: some_place.rooms.meetings.where("DATE(meetings.starts_at) = ?", Date.today) Nice and simple.... > It's my first Rails database, and my first ever relational > database for anything :) I have been reading up on it a lot ;) You have learned well, young padawan.... ;-) -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.