Just out of curiosity and lack of a definite answer...
I was just looking at some data that is sent from a 3rd party to us, and their "Gender" field is a [0,1] denoting either a Female (0) or a Male (1).
Is there any better reason to use [0,1] over ["F","M"]?
Does it depend on the scenario and the intuitiveness between a field and its value?
Data access speeds and/or size constraints?
If the moon is full?
You can declare a boolean host variable as follows: EXEC SQL BEGIN DECLARE SECTION; boolean flag; EXEC SQL BEGIN DECLARE SECTION; In the Informix ESQL/C program, the following values are the only valid values that you can assign to boolean host variables: TRUE.
There is boolean data type in SQL Server. Its values can be TRUE , FALSE or UNKNOWN . However, the boolean data type is only the result of a boolean expression containing some combination of comparison operators (e.g. = , <> , < , >= ) or logical operators (e.g. AND , OR , IN , EXISTS ).
Zero ( 0 ) is converted to FALSE. Any non-zero value is converted to TRUE.
Since sex is not actually binary - there is a continuous range of 'intersex' conditions between male and female, as well as beings with no sex at all - it's best to use a floating-point type. 0 for female (being the default, at least in mammals), 1 for male, with intermediate values for intermediate conditions, and NaN for those with no value.
But remember, this will never be fully applicable, because there is no type for the human heart. Although complex is often a good approximation.
A major advantage is that a column that allows for more than two values can be extended naturally if your assumptions change.
Also, more philosophically, our notions of gender/sexuality are much more fluid than accounted for in a binary field. For instance, I was hired to fix a major government application in Massachusetts when same-sex marriage laws were passed, because lots of assumptions were made about marriage that were later invalidated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With