There is an abstract user. For him, there is a questionnaire. An example of questions with the options for answers below.
1) What is your parrot's name? (single choice of several values - type radio)
- Kesha
- Gesha
- Sasha
2) Who do you like? (Abstract string - string)
3) When do you feed a parrot? (Multiple choice from multiple values - checkbox)
- In the morning
- Happy
- In the evening
- Is always
Storage of fields of the questionnaire - fields id | Question | Answer 1 | What is the name of the parrot? | serialize (array ('Kesha', 'Gesha', 'Sasha')) 2 | When do you feed a parrot? |
User selectable storage
id | user_id | field_id | value 1 | 1 | 1 | Кеша 1 | 1 | 2 | Даже не знаю чуваки. With this storage, we are fine, we can do filtering by fields of the first type (which is important right away in MySQL).
But there is a problem with filtering a field of the third type, since several values can be selected there.
An excellent solution for a checkbox would be to use a bitmask, but the problem is that we are dealing with fields of not only this type. Yes, and collect normally the bits of what we want will be problematic.
Who can push to the solution? Or submit a good idea or reference?