I have a table with my user's information, including their address, city, country, phone number, website, social network links, etc... And they have the option to select which of those information they want displayed on their public page.
So instead of creating some boolean column in the database for each one of those values, I want to create a single integer column that would hold one number which indicates all of those options in binary-style.
For example if the first (binary) digit represents your address, the second is your country and the third is your Facebook page. You want to display your address and your country, but not your Facebook page, then that would equivalent to 1
, 1
and 0
, meaning I would store a 6
in the database.
In my code (PHP), I would display it like:
if($value & 4) { showAddress(); }
if($value & 2) { showCountry(); }
if($value & 1) { showFacebookPage(); }
My question, for consistency, readability, and collaboration purposes, is only this:
What is the name for this kind of value keeping? Or rather, what should be the name of this column in my database?