0

I need to model a table, and relationship that represents the following: The hours of operation of a company.

My initial idea is, 1 Company - N business hours. That's because depending on the day, the timetable may vary. Example: On Saturdays the company works until 12:00 PM. And from Monday to Friday, it works until 6:00 PM. Do you understand? These are things that vary and I need to have this in a table.

It's confusing for me, what fields do I put to answer the following question: Which companies are open now?

My database is mysql

  • So it seems like you need a day column too!?! – Strawberry Apr 15 '18 at 08:24
  • 1
    Please show us some sample data. I think your question is too vague as it stands right now. – Tim Biegeleisen Apr 15 '18 at 08:33
  • I can not go on. You do not have to worry about the table, and how it can be queried. – brubdeds brindeds Apr 15 '18 at 08:53
  • In the end I need to do a search on the companies that are open. But I do not know how to put them together for this kind of problem. – brubdeds brindeds Apr 15 '18 at 08:59
  • 1
    One of my most popular answers for some reason https://stackoverflow.com/questions/2721533/sql-for-opening-hours/2721596#2721596 . Have you tried searching before posting? Using this, adding a column for the company ID, and doing basic time operations in a query will yield you the results needed. – Alex Apr 15 '18 at 09:34
  • Related, but for Postgres: https://stackoverflow.com/questions/22108477/perform-this-hours-of-operation-query-in-postgresql/22111524#22111524 – Erwin Brandstetter Apr 15 '18 at 13:17

0 Answers0