How to store repeating events i db

Posted on 2012-09-04
Last Modified: 2012-09-11
I'm given the task to create a calendar on our club site - I will probably be using FullCalendar ( and for sure php/mysql as backend.

But I'm not sure how to save repeating events in the db, so I'm looking for input and articles on that issue.

Eg. A user creates an event "Clean refrigiator" that should repeat every weekday at 7:30

Instead of creating 365 events * N years - how should I store these events in the mysql db so it's quick to retrieve them again ?

Any input is appreciated.
Question by:internetservice_dk
    LVL 50

    Expert Comment

    by:Julian Hansen
    In addition to setting the fields for when to run you set an expires date in the future for when the event is valid until

    For repeating forever dates pick something far enough in the future that when it becomes a problem they won't ask you to fix it.

    Then when you retrieve the events simply look for events that have not expired.

    You can run a regular cleanup job to cleanup events that have expired (simple solution) or build in a cleanup into your query.

    I can give you more detail on the exact mechanics of how to do this - post back if you would like more detail

    Author Comment

    julianH - thanks for your reply.

    Perhaps I was not being specific enough - the example where an event is repeated every day is perhaps too simple.

    So the user adds an event thet should repeat every monday @ 08:00, every wednesday @ 10:00 and every second saturday @ 13:00

    I need to be able to track if each task has been completed (could be clean refrigiator or similar task at a workplace)

    Best regard,
    LVL 50

    Accepted Solution

    I did understand - was answering the question on how to get around having to save N events in the db - the solution is to use an expiry date.

    If you need the full spec for how to save scheduled events in the db then these might be of assistence

    Author Closing Comment

    Thanks for the links - they got me on the way :)
    LVL 50

    Expert Comment

    by:Julian Hansen
    You are welcome - thanks for the points.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now