p9807
p9807

Reputation: 615

MySQL - Ideal way to store business hours information

I want to store a standardized set of information about when a business is open for each day of the week. Is there a standard way to easily store/alter this in MySQL?

Thanks!

Upvotes: 3

Views: 1401

Answers (2)

SamT
SamT

Reputation: 10610

Database design is really an art, there are many different ways to design schemas.

I would start with a table, say "business_hours", and make the following columns:

- business_id (integer, auto increment) 
- business_name (varchar, largish like 255)
- open_monday   (varchar, integer, however you want to represent the data.)
- close_monday

repeat pattern of the last two columns until Sunday.

That's one way to do it, it's not a very sophisticated way, but it will work. Because I don't fully understand your context (i.e. what's using it, who's looking at it), it may be slightly off.

Upvotes: 4

Jem
Jem

Reputation: 769

To me it seems like this might actually be better accomplished via html. Assuming the hours are very standard and won't change often it might just be easier to code them in with out making a sql table or database for these store hours. Now if they change a lot and are dependent on time of year, whether, or they change based on what the company is doing at the time then its probably easier to go the database route. If this is the case SamT has provided the answer as to how to catalog and store it.

Upvotes: 0

Related Questions