Re: calendar db-repeating event: insert or select?

From: Joe Celko <71062.1056_at_compuserve.com>
Date: Tue, 05 Sep 2000 15:56:38 GMT
Message-ID: <8p353e$po4$1_at_nnrp1.deja.com>


>> ... calendar feature where events can be repeated over days, weeks,
months and years. Collecting the information is easy enough, but what is the best way to handle it? For each repeating event, should I insert a new record, or would it be better to do some computations on a table to come up with the correct records when called? <<

I would tend to favor storing the events as separate rows in a calendar table. There is a story here; one calendar system I saw used would read the day's actions, then a trigger would insert the next repetition of the event by adding a fixed period (week, fortnight, month, year, or whatever) to that date. The idea was to keep the table small and fast. If one of the events was dropped or moved, the change cascaded. Using only simple fixed periods messed up lunar holidays like Easter.

Put the "smarts" in the host program and pre-load the table with 10 or 20 years of known holidays.

--CELKO--
Joe Celko, SQL and Database Consultant
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc) which can be cut and pasted into Query Analyzer is appreciated.

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Tue Sep 05 2000 - 17:56:38 CEST

Original text of this message