I’m working on an event calendar, using MySQL and PHP.
I already set up a table with the dates and hours and the calendar works pretty well. I have to make an event calendar for multiple rooms, so I was thinking I would have to create a table for every new room that is added to the DB.
Considering my calendar is divided by intervals of half and hour, my index column goes like this: 2010-1-1 00:00:00, 2010-1-1 00:30:00, 2010-1-1 01:00:00 and so on, for about 25 years into the future. Also there’s another column with the event ID.
I think it would take too much time, as well as space, everytime I add a room, because a new HUGE table would have to be created. Is there a simpler approach for this?
If you create an event table containing following:
You can then check if the room 1 is occupied for between 11:30AM and 1:30PM range with this:
Anything greater than 0 indicates existing events in room 1 for this datetime range. Or you can return conflicting event and show it to the user by select
*instead ofcount(event_id)