问题
[Edit] Sorry I mean no offence to women, this question troubled me several times. I just like to know a conventional or universal way (in both database and... other programming languages). Thank you.
Is there a conventional way to show gender using boolean?
Are they the same in all languages? JAVA, C, Objc, databases?
I guess we should use true (1) for male and false (0) for female?
Thank you.
回答1:
true (1) for male and false (0) for female
回答2:
If you want to use a boolean it might be a good idea to call your variable either isMale
or isFemale
rather than just gender
to make it clear what the value true
means.
However in many countries it is not legal to require people to disclose their gender if they don't wish to, so you may have to use an enum with three values:
Female
Male
Unknown
回答3:
What's wrong with a single character, containing one from the set {'m','f','n'}
for male, female and not applicable?
I'm sure you're not that hard up for space that you need to pack all your genders into bitmaps.
来源:https://stackoverflow.com/questions/8005681/what-is-the-convention-to-use-boolean-for-gender-in-programming-languages-true