If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Storing 'hours or operation'

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-08-09, 10:20
kwyjibo kwyjibo is offline
Registered User
 
Join Date: Jun 2009
Posts: 4
Storing 'hours or operation'

What is the best way to store 'hours of operation' in a database? We have 21 branches, and the hours for each vary quite a bit. I don't want to just hard code it, because I need the information in more than one location...not to mention for the map application api. Should I just store the information as a long string of text, html line breaks included? Is there a better way?
Reply With Quote
  #2 (permalink)  
Old 06-08-09, 10:39
dportas dportas is offline
Registered User
 
Join Date: Dec 2007
Location: London, UK
Posts: 732
Make branch and time part of the key:

OperatingTimes {BranchNum, StartTime, EndTime} KEY {BranchNum, StartTime};
Reply With Quote
  #3 (permalink)  
Old 06-08-09, 11:17
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
I assume that your branches work the same schedule every week, but different hours on different days. If so, you have two possible solutions.

The "all encompassing" solution is to store open and close times by calendar day. This allows you to easily deal with holidays, summer/winter hours, and special events (such as a branch being open late on the first or the third of every month). It uses more disk (rows), but it is very simple and it allows you nearly infinite flexibility.

The "week with exceptions" allows you to record a "standard" week schedule, then only record the days that are non-standard. This is a bit more complicated, but it uses a lot less storage.

The "week without exceptions" allows you to store one row with branch, day-of-week, open time, and close time. This is very efficent in terms of space, but doesn't allow for exceptions (no holidays, etc).

The "same schedule every day" records branch, open time and close time. It assumes that your branch observes the same schedule every day with no exceptions. This is what I think that dportas was discussing.

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #4 (permalink)  
Old 06-10-09, 14:13
kwyjibo kwyjibo is offline
Registered User
 
Join Date: Jun 2009
Posts: 4
Smile Thank You!

Sorry, got sidetracked with a different project for a couple of days...

Thank you very much for your responses! They were most helpful. I think the 'week with exceptions' will work best in this situation. While branch hours vary widely between them, each branch has basically the same schedule all year. The only exceptions being two branches that have 'summer hours'. And, of course, holidays.

I'll try that one out. Thanks again for the responses!

--Alex
Reply With Quote
  #5 (permalink)  
Old 06-10-09, 16:29
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Probably easiest, from a software development perspective, to switch to being open 24 hours per day, seven days per week. Makes your customers happy too.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On