Saving schedule in mysql

I am interested in a way to keep my users โ€™schedules. I need to save the day of the week and the hours when it will be available. It can be from 8:00 to 12 or from 9:00 to 12, and then from 15:00 to 18:00 in between. I'm not interested in decoying database operations, I just need to add and get dates when necessary.

+4
source share
3 answers

I am not interested in database operations

An alarming bell rang in my head. Does this mean that you also do not need to fully analyze the problem before it is implemented?

There is very different semantics associated with managing an unlimited schedule of recurring events with a well-defined pattern (for example, every Tuesday from 9-12) compared to storing a fixed schedule (for example, Tuesday, April 5, 9-12). Obviously, the latter cannot be performed with an indefinite time interval, although during a certain timeframe you can implement the former using the latter model.

If this is simply a matter of recording historical events, then the data is limited, and so the second approach is more appropriate. But for future events, you probably need both methods, but the first one is hard to implement at the database level.

+5
source

Here is a link to a site that solves common problems with MySQL queries, from these examples you can rebuild your structure.

http://www.artfulsoftware.com/infotree/queries.php#98

This will help with "Available appointments."

+2
source

I modeled it like this:

int DayOfWeek // maps to System.DayOfWeek enum time(0) Start // smallest possible time with seconds precision time(0) End 
0
source

Source: https://habr.com/ru/post/1346240/


All Articles