We are currently developing an application in which several objects have associated opening hours. Hours may span several days or may be contained within one day.
Ex. It opens on Monday at 6:00 and closes on Friday at 18:00.
or
It opens on Monday at 06:00 and closes on Monday at 15:00.
In addition, an entity can have several sets of hours of work per day. So far, the best design I have found is to determine the opening hour, which is as follows:
StartDay, StartTime, EndDay and EndTime.
This design provides the necessary flexibility. However, data integrity is becoming a problem. I cannot find a solution that would prohibit overlapping gaps (in the database).
Share your thoughts.
EDIT: Microsoft SQL Server 2008 R2 Database
source share