cbojer
cbojer

Reputation: 63

Storing available dates of the week in MySQL

I'm working on a booking application, and in the backend, the user will be able to specify which days of the week he wants his venue available on. For instance, he might choose only to make his venue available on friday and saturday.

My question is, how would I go about storing this data in the smartest way?

The first thing that comes to mind, is saving it on the venue's table, but that would as far as I can tell, mean storing it in a comma-seperated list, which is bad.

The other would be a table for available dates, containing the available day as an int (or is this wrong?) and a foreign key for the venue_id.

Upvotes: 3

Views: 153

Answers (1)

Bobby
Bobby

Reputation: 2928

Don't use a comma delimited string. Create a second table called availableDates.

Use the venueId as a foreign key in the availableDates table.

As you say the availableDates table only needs to be 2 columns. One for the foreign key and one for the day which will be an int.

Upvotes: 1

Related Questions