Creating a match system with days of the week and different periods between two tables

1

While doing a university project, I came across a problem that proved to be a hindrance. I need to create a system that requires a user to select days of the week and periods (night, daytime, morning) in a way that is convenient for them. Ex: user is available on Monday morning and afternoon and on Sunday night.

Having selected the days and available periods (via checkboxes on the site), this user will come across "works and projects" that are within his profile and available days. Since projects should also have this option to select their days and periods at the time of their creation.

The big problem is in the creation of this specific part, I broke my head with a few tables and on how to cross that information in the bank, but nothing seemed to work.

    
asked by anonymous 25.03.2017 / 06:34

1 answer

0

A common practice is to use the binary sequence for operations like these. In the volunteer table, you would have a property to store the available days:

  • Sunday - 1000000
  • Monday - 0100000
  • Tuesday - 0010000
  • Wednesday - 0001000
  • Thursday - 0000100
  • Friday - 0000010
  • Saturday - 0000001

When you want to accumulate the days, make an OR between the values. When the volunteer can second , Tuesday and Saturday , 0110001 (or 49, which is the corresponding decimal)

For the period it does the same logic:

  • Morning - 100
  • Late - 010
  • Night - 001

When the volunteer can, morning and night will be recorded 101

    
25.03.2017 / 14:25