I have to model a calendar, and that i got a bit of ideas myself, but I'd like some input from everyone :)
The domain is the following: A calendar consists of time records (think google calendar here). For every group and day within the calendar, I've got a starttime as well as an endtime, denoting time its likely to go in new visits between. A scheduled appointment includes a starttime as well as an endtime too.
When someone uses the calendar (s)he will discover a quantity of available time slots, each having a amount of fifteen minutes.
Now, I emerged with 3 ideas:
Make use of the start- and endtime from the visits
By doing this, each time I have to render the calendars time slots, I must calculate them in line with the start- and finish duration of the visits, which scales poorly concerning CPU time.
Overlook the visits and just make use of the time slots
By doing this, each time a new appointment is created, time slots is going to be up-to-date, and therefore only computes time slots when there is a CRUD operation with an appointment. By doing this, I'll get nice CPU scalability, however, persisting constantly slots will require up much space.
Have a cache in memory of times slots and just persist the visits
By doing this, I obtain the best of both mobile phone industry's - Good CPU scalability, and nice persistence scalability. The issue is, it's a (fair) assumption any time time slots are calculated, it is extremely likely that the new appointment is going to be made, thus invalidating the cache. I have to run some tests about this method of discover whether it's achievable.
Before I recieve into an excessive amount of work to do simulations and so forth, I must determine if anybody has other ideas about how exactly this may be done more scalable (concerning CPU and persistence).
If you think you should know much more about the domain before considering this, you can publish a comment and I'll update the question As soon as possible :)
Wishing someone has some miracle for me personally )