I am writing code (using MySQL) to solve a problem similar to the following:
There are 20 boolean options (per every user).
Should I store 20 ENUM('false','true') or put into a table only IDs of these options which are true (so probably having less than 20 rows per user)?
If new options are likely to appear and you don’t filter by the options, you may as well go with a
EAVstructure (a record per option).This way, you can add new options more easily (no change to metadata).
Assuming that the options values are either
TRUEorFALSE(noNULLpossible), you should create records only for non-default option values (TRUEin your case). An absence of the record would mean false.To retrieve all options, you could use this:
, which would give you dynamic output: