From: James Herdman Date: 2008-06-05T01:31:30+09:00 Subject: Re: Commercial Calendar Calculations ------=_Part_4178_15856207.1212597143502 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Oh, I see! So if you wanted to get the Date object corresponding to a row you'd just dump those values into Date.civil. Smart! I'm curious about your occurrences table. I think I understand this to be one-time-only events. Is that correct? James On Wed, Jun 4, 2008 at 11:07 AM, Donald Ball wrote: > On Tue, Jun 3, 2008 at 7:59 PM, James Herdman > wrote: > > Donald, > > I'm definitely interested in hearing about the details. I'll be having > to > > deal with an RDBMS as well. > > Sure thing, I'll describe briefly here and you can feel free to email > me if you have further questions. My data model included a table of > events, a table of occurrences for events on specific dates, and a > table of recurrences for events that recur. The recurrences table has > columns for event id, weekday, monthweek, and monthday; an event > occurring on all Mondays would have 1 for weekday and null for the > others, while an event occurring on the last Friday of a month would > have 5 for the weekday and -1 for the monthweek. I created a view > joining these data (events, occurrences, recurrences) against a table > of dates, excluding holidays, and end up with a virtual table > consisting of a row for every valid event-date pair. > > Given that the date functions in SQL aren't standardized, I'd thought > this would have been practically difficult to bundle up as a rails > plugin, but it now occurs to me that I could store the date parts > (e.g. weekday) in the table of dates, eliminating the need for any > date functions in the database. I may give that a whirl this weekend. > > - donald > > ------=_Part_4178_15856207.1212597143502--