Answer the question
In order to leave comments, you need to log in
How would you store work time?
There are organizations, each has an opening time (08:00) and closing time (18:00) and there are 7 days of the week - in each of them, the time can theoretically be different, although it usually differs only for Fri, Sat, Sun.
Total 14 values. They are not searched.
Question: how to organize such data in a database?
Do 14 fields for each organization? This will make the request much heavier, and does it make sense if there is no search? Serialization/deserialization? Violates the principle of 1 cell - one data.
Answer the question
In order to leave comments, you need to log in
Well, for flexibility, I would recommend this:
1) First table: id, time (where time is from 0 to 24, id is pk)
2) Second table: id, day (where id is pk, day is from 0 to 7)
3) Cross-table (schedule)
id, day_id, start_time_id, end_time_id, organization_id
If there is no search and scaling and generally adding lunch, for example, is not observed), then you can do serialization.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question