I've read some of the papers out there describing data storing methods for recurring events, but I'm still trying to wrap my head around the best practice, especially concerning MongoDB.
My main concern is to cheaply retrieve all of the events that occur within a given timeframe. My secondary concern is to modify and alter single occurrences without taking the entire event chain out of whack.
Looking at others who have asked similar questions, I have come up with a possibility. I'm not completely sold on it, and would love some pointers in the right direction.
My Idea: Within each Event document, have...
- a recurring string field that closely matches the iCal standard
- an "occurrences" embedded document or array field that contains changes/edit on specific occurrences (such as changing the description or start time, or canceling a single occurence).
- an occurrence start and end field to define easily queried boundaries of the recurrence rule
Pros:
- able to store changes and still maintain association to other events
- easily queried, my model on the business side would have to construct each event though
Cons/Potential Problems:
- if editing an event, and a user decides to mark changes as applying to "all events" - how to keep events that have already past from being altered