Storing repeating events for a calendar
I have a calendar application written in ColdFusion. One of the issues that came up in development was how best to store repeating events. There seem to be two main approaches to this:
- Use one database table to store information about the event and only its repeat pattern (ie. this event repeats every day/week/month/etc). You then use SQL or a programming language to dynamically calculate which days the event should appear on the calendar.
- Use two tables. One stores information about the event and its repeat pattern, the other has a record for every day that an event is repeated.
The advantage of method 1 is that it takes up less storage and can handle infinitely repeating events.
The disadvantage of method 1 is that it is slow to calculate the repeats.
The advantage of method 2 is that it is very quick to retrieve and display the data.
The disadvantages are more storage required and you can't have infinitely repeating events (there are workarounds though).
This page has a good discussion of both approaches.
Speed has become an issue so I am going to implement method 2 but limit repeats to 2 years.

0 Comments:
Post a Comment
<< Home