I'm currently trying to work out the best way to store a business' hours of operation in a database.
For example:
Business A has the following hours of operation
- Monday: 9am - 5pm
- Tuesday: 9am - 5pm
- Wednesday: 9am - 5pm
- Thursday: 9am - 5pm
- Friday: 9am - 5pm
- Saturday: 9am - 12 Midday
- Sunday: Closed
Currently I'm have a data model similar to the following
CREATE TABLE "business_hours" (
"id" integer NOT NULL PRIMARY KEY,
"day" varchar(16) NOT NULL,
"open_time" time,
"close_time" time
)
where the "day" is restricted to a choice of the 7 days of the week in code (through the ORM). To test if a business is closed on a certain day it checks if the open_time and close_time are NULL. It is related to the business through a intermediate table (Many To Many Relationship).
Does any one have any suggestions for this database scheme? Something about it doesn't seem right to me.