Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing available dates of the week in MySQL

Tags:

mysql

days

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.

like image 808
cbojer Avatar asked Jan 24 '26 17:01

cbojer


1 Answers

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.

like image 168
Bobby Avatar answered Jan 27 '26 07:01

Bobby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!