I want to store opening times for different shops in a database. At the moment I am working with the simplest solution:
CREATE TABLE opening_times(
shop_id
Normalise your data
store it as
shop_ID, Weekday, Start_hour, end_hour
weekday can have values between 1 and 7, as an output of
SELECT DAYOFWEEK('2007-02-03')
start hour and end hour can be stored in time http://dev.mysql.com/doc/refman/5.0/en/time.html
with this you would have everything covered
To find hours on a date for a shop you would do
select start_hour, end_hour from table where weekday=dayofweek(curdate()) and shop_id=1
Need 2 time intervals for a day for a shop? no problem,
`shop ID, weekday, start_hour, end_hour`
1; 1; 08:00:00 ; 09:00:00
1; 1; 10:00:00 ; 11:00:00
For exceptions, you can add an exceptions table
with the date and the shop. You can query that, and if it's null(no exception), return opening hours. Alternatively you can store every date for every shop, but that would bloat your data.