views:

1052

answers:

3

I'd like to display a repeating event on a date/time display in an app. This date time display can take the form of a calendar, but it could also just be a list of upcoming events.

What is the best way to handle tracking this event that can repeat?

For example: Should the event be stored once in the database and projected out / repeated several times in the display code? Should the event be stored several times and then just rendered?

+1  A: 

I think it depends on type of event it is. Is it like Christmas where once it comes along and happens you really aren't interested in it until the next occurrence? Or is it a task like, "Make sure I call my mom every month", where if it happens and you missed it you wouldn't want it to go away?

One way I recently implemented the latter was to have a record that had next_occurrence (date), reoccurence_period (weekly, monthly, yearly, etc) columns. So that as the next occurence approched it would show up in the list. Once it passed the list item would have a recycle icon that once pressed would update the record to the next future occurence.

Again, i'm not sure if this applies to your situation, but it worked well for mine.

Jamal Hansen
+2  A: 

I did something like this before and I based my schema off of SQL Servers sysschedules table.

http://technet.microsoft.com/en-us/library/ms178644.aspx

The schema linked above will allow you to store the schedule for a job (event). Then you can calculate what dates the event occurs on based off of the schedule. This may be a lengthy calculation, so I would try to cache that result somewhere.

Bob
+2  A: 

I'm not sure if I got this link from this site or not. Anyways, Martin Fowler discussed this on his site awhile ago.

http://martinfowler.com/apsupp/recurring.pdf

Austin Salonen