Fishball
Fishball

Reputation: 11

Best practice for timetable-like database design

I was wondering what is the best practice for timetable-like database design? Take for example businesses in a business directory. They have opening / operating hours; Monday to Sunday followed by opening time and closing time for each day. As such what is the best practice for table that contains such information?

The first thing that comes to my mind is having 7 columns for each day in a table. But that doesn't seem very practical and my insecure side tells me that it'll probably put more load to the database.

Any suggestions?

Thanks in advance.

Upvotes: 1

Views: 961

Answers (1)

Dan Grossman
Dan Grossman

Reputation: 52372

Four columns: business, day_of_week, opening_time, closing_time

This table contains one row for each day of week, with its opening/closing hours. The business column is a foreign key referencing the main table with the business information in it.

Upvotes: 1

Related Questions