Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Designing a Calendar system like Google Calendar [closed]

I have to create something similiar to Google Calendar, so I created an events table that contains all the events for a user.

The hard part is handling re-occurring events, the row in the events table has an event_type field that tells you what kind of event it is, since an event can be for a single date only, OR a re-occuring event every x days.

The main design challenge is handling re-occurring events.

When a user views the calendar, using the month's view, how can I display all the events for the given month? The query is going to be tricky, so I thought it would be easier to create another table and create a row for each and every event, including the re-occuring events.

What do you guys think?

like image 504
public static Avatar asked Aug 15 '08 19:08

public static


People also ask

Is there something better than Google Calendar?

TimeTree (Android, iOS, Web) It's also one of the best free online calendar apps available. You can create different event calendars within the app, such as a calendar for personal or workplace events.

Can you design Google Calendar?

You can only create new calendars from a browser and not from the Google Calendar app. Once the calendar is created, you can find it on your browser and in the app. On your computer, open Google Calendar. Create new calendar.


1 Answers

Attempting to store each instance of every event seems like it would be really problematic and, well, impossible. If someone creates an event that occurs "every thursday, forever", you clearly cannot store all the future events.

You could try to generate the future events on demand, and populate the future events only when necessary to display them or to send notification about them. However, if you are going to build the "on-demand" generation code anyway, why not use it all the time? Instead of pulling from the event table, and then having to use on-demand event generation to fill in any new events that haven't been added to the table yet, just use the on-demand event generation exclusively. The end result will be the same. With this scheme, you only need to store the start and end dates and the event frequency.

I don't see any way that you can avoid having on-demand event generation, so I can't see the utility in the event table. If you want it for the sake of caching, then I think you're taking the wrong approach. First, it's a poor cache because you can't avoid on-demand event generation anyway. Second, you should probably be caching at a higher level anyway. If you want to cache, then cache generated pages, not events.

As far as making your polling more efficient, if you are only polling every 15 minutes, and your database and/or server can't handle the load, then you are already doomed. There's no way your database will be able to handle users if it can't handle much, much more frequent polling without breaking a sweat.

like image 116
Derek Park Avatar answered Sep 21 '22 12:09

Derek Park