Skip to main content

Posts

Showing posts from October, 2010

Recurring Events in MySQL

This article describes how to store recurring events in a MySQL database. This might be useful if you're building a calendar or some sort of job scheduler. The table for storing recurring events is inspired by cron http://www.manpagez.com/man/5/crontab/ . You will notice obvious similarities between the table structure and the structure of a crontab file. The table structure also uses the SET datatype in MySQL. You should be familiar with this type before you continue. Documentation can be found here . Just as an example, I'll create a table that can be used to schedule the automatic updating of files. Here is the SQL statement you might use to create this table: CREATE TABLE `File Update Scheduler` (  `Filename` varchar(255) NOT NULL default '',  `LastRefreshed` timestamp NULL default NULL COMMENT 'Timestamp indicating when the file was last refreshed',  `ScheduledMinutes` set('0','15','30','45') NOT NULL COMMENT