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

Asked

Viewed 177 times

1

When I was doing a university project, I came across a problem that proved to be an obstacle. I need to create a system whose user is required to select days of the week and periods (night, day, morning) in a way that is convenient for him. Ex: user is available on Monday morning and afternoon and Sunday night.

Selected the days and periods available (via checkboxes on the site), this user will come across "jobs and projects" that are within their 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 some Ables and on ways to cross this information in the bank, but nothing seemed to me that would work.

Visto que as relações entre as tables ainda está por fazer

  • 1

    An idea that would work would be to register everything in the voluntary table, but would be huge and unviable.

1 answer

0

One practice used is to use 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 is to make one OR among the values. When the volunteer can second, tuesday and saturday, shall be recorded 0110001 (or 49, which is the corresponding decimal)

For the period makes the same logic:

  • Morning - 100
  • Afternoon - 010
  • Night - 001

When the volunteer can in the morning and evening will be recorded 101

  • One source you can use: http://sqlfool.com/2009/02/bitwise-operations/

  • Thank you very much! But there is still one question left. Each volunteer contains all their days of the week, linked to a period. Thus would be the relationship of these tables, since in the future I will make an INSERT for each volunteer, each day and each day a different period.

  • Make another table only with relations, voluntary id, days, periods.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.