4
I need to create a table that contains days and hours of operation of an establishment, a kind of agenda. This table should represent every day of the week and on each day contain the opening and closing hours. The challenge is to create this table in a way that does not have redundant data and that facilitates the search for the opening hours of a given day.
For example, I will need to pick up the day of operation of the establishment next Wednesday, or today’s time. There is still another factor that are the holiday days (that the schedule will certainly be different from the normal days, taking into account that the establishment is open). Facebook has something similar on the corporate pages.
In the image a representation of the idea (the first time is the opening time and the second the closing time). I will use Mysql.
How are you going to use this? The always fixed sermon times for the specified days ? Your fields will be of what type? string ? time ??
– Marco Souza
Theoretically the times will be fixed. Once defined, with some exception, they will not be changed anymore. As for the fields, I have not defined the type.
– Danilo Miguel
and how will you show it in the same way as this in your table above? side by side times ?
– Marco Souza
No. In fact I will filter the "open" establishments according to the day the system is accessed. p.e.: Monday, 19:20 hours, the user accesses the system and will see only the companies opened that day and time. In the case of the admin of the establishment/company, it needs to have a global view of the days and times.
– Danilo Miguel
Then you have a company direct relation 1----> Many schedules, if you create fields with the varchar() type for the schedules you could create your table with the fields you specified above by adding the company’s FK in the table.
– Marco Souza
See if the answer meets what you need.
– Marco Souza
@Gokussjgod I am testing an option very similar to the one you indicated to me, with some small changes. As soon as I finish I give my feedback.
– Danilo Miguel
Okay, see that the database used in the answer is sql server, but the logic would be the same for your database. when I’ve had more time riding something on the fiddle
– Marco Souza
@Gokussjgod, I followed a little of what you suggested with the proposed answer in that answer (http://answall.com/questions/44452/gravar-no-banco-dados-o-hor%C3%A1rio-de-expediente-e-realizar-uma-consulta?answertab=active#tab-top) - which are quite similar, by the way. So far you’re treating me well.
– Danilo Miguel
You managed to solve your problem?
– Marco Souza
@Danilomiguel if I could help with my answer, you can accept the answer by clicking on the left side of it. If you need any more help, let us know
– Tmc