In the application we are creating (iOS / Swift, Android), we have a settings page when the user wants to receive push notifications. One of the parameters is the selection by the user of the days of the week.
My question is how to save this parameter as one variable, not seven booleans. This parameter will be sent to the server / database to be saved, and I thought we could just use a single byte field in the database. Instead monday=true, tuesday=false, ..., I would like to use, for example, "10001010", where 1 is true and 0 is false, which will translate to monday=true(1), tuesday=false(0), etc(this Monday is the first day of the week that it ...).
Is this a valid way to store such data? Can I create such a byte? Or is it a more practical practice using the / char [] string "10001010"? Or can databases (e.g. MySQL) store bool [] (10001010) as a single field? Or is there another, best practice for this? The method used for permissions also came to mind (you know, just 777)
Of course, some options will require the server to use the same logic for the variable, but in this case there is no problem.
A brief explanation. I need seven boolean elements, one for each day of the week, and I want to store it more efficiently than one variable per day. Is there a "best practice"?
source
share