Boolean data type for Male/Female Field is incorrect? (1 Viewer)

MrBrightside

Brightest Member
Joined
Jan 18, 2010
Messages
2,033
Gender
Undisclosed
HSC
N/A
There was this question saying which data type would be best relevant to to the Male/Female Field in a database.

(A) Number
(B) Boolean
(C) Character
(D) Alphanumeric

The correct answer is (C). Now From previous knowledge I thought a boolean value can be substituted for any two options. E.g. M or F. But My teacher said that boolean can only be [true or false] OR [Yes or no]. -.-

Is this a stupid question or a trick question.
 
Last edited:
B

boooooooooooooo

Guest
of course it's right, r u a moron?

it says "most relavent". Yes, if there are only two choices then if you aren't a man you are obviously a women by basic deduction. But a "1" or "0" takes up as much memory as a "M" or "F" , so you might as well use characters.

Come on, you're a serious dumbass if you needed to ask that. I didn't do IPT and know that, it's common sense. Hows failing maths going? :p

LOL ATAR Aim: The centre of (x-9)^2 +(y-2)^2 = 5^2

do you really think you should be posting maths jokes like that? Are you sure you can understand it? :p

92 huh , that won't happen XD
 

MrBrightside

Brightest Member
Joined
Jan 18, 2010
Messages
2,033
Gender
Undisclosed
HSC
N/A
of course it's right, r u a moron?

it says "most relavent". Yes, if there are only two choices then if you aren't a man you are obviously a women by basic deduction. But a "1" or "0" takes up as much memory as a "M" or "F" , so you might as well use characters.

Come on, you're a serious dumbass if you needed to ask that. I didn't do IPT and know that, it's common sense. Hows failing maths going? :p

LOL ATAR Aim: The centre of (x-9)^2 +(y-2)^2 = 5^2

do you really think you should be posting maths jokes like that? Are you sure you can understand it? :p

92 huh , that won't happen XD
You just said it yourself. A 1 / 0 is the same as a F or M.
 

hello-infidel

Banned
Joined
Sep 9, 2011
Messages
5
Gender
Undisclosed
HSC
N/A
You just said it yourself. A 1 / 0 is the same as a F or M.
NO, god think lol. i'll be nice and explain it now (because you most likely have no chance of doing well anyway lol).

Think.

If have just a character to determine the gender (either M or F) then I only need ONE data entry and I can look up the person and get their gender INSTANTLY by looking at the character.

Now, if you were to do it using boolean , you would either:

1. Need two separate data entries (male and female ) for each employee and if they were a male then you would put a 1 in the male section and a 0 in the female section but this would result in lots of wasted memory.

2. You could just have one data entry (ie "Male) and if they are male you put a 1 and if they are female you put a 0 but this would also be a pain. Even though you can logically figure out which one they are by deduction (obviously, if they have a zero in the male section then they must be female!) it takes more time and is less effiecent.

In the character way you can determine the gender INSTANTLY and you are only taking up one section of memory, you don't have to think. With the boolean way you either need twice the memory (which is a waste) or you need to actually think!. It's obvious which one is better.
 

MrBrightside

Brightest Member
Joined
Jan 18, 2010
Messages
2,033
Gender
Undisclosed
HSC
N/A
NO, god think lol. i'll be nice and explain it now (because you most likely have no chance of doing well anyway lol).

Think.

If have just a character to determine the gender (either M or F) then I only need ONE data entry and I can look up the person and get their gender INSTANTLY by looking at the character.

Now, if you were to do it using boolean , you would either:

1. Need two separate data entries (male and female ) for each employee and if they were a male then you would put a 1 in the male section and a 0 in the female section but this would result in lots of wasted memory.

2. You could just have one data entry (ie "Male) and if they are male you put a 1 and if they are female you put a 0 but this would also be a pain. Even though you can logically figure out which one they are by deduction (obviously, if they have a zero in the male section then they must be female!) it takes more time and is less effiecent.

In the character way you can determine the gender INSTANTLY and you are only taking up one section of memory, you don't have to think. With the boolean way you either need twice the memory (which is a waste) or you need to actually think!. It's obvious which one is better.
What if, you made a drop down list with two values, Male and Female. Is that still considered as Boolean as it's either one or the other.
 

pwoh

O_O
Joined
Jun 28, 2008
Messages
709
Location
Behind you
Gender
Female
HSC
2010
Uni Grad
2016
@Troll - a '1' or '0' does not take as much memory as a 'M' or 'F' if you are storing it correctly. Boolean = two values only, pretty sure there are more than two types of characters :p

@MrBrightside
There's an extensive discussion here, I'd look at OMG Ponies' answer.
http://stackoverflow.com/questions/4175878/storing-sex-gender-in-database

IMO a strange question to have in a HSC exam.
 

MrBrightside

Brightest Member
Joined
Jan 18, 2010
Messages
2,033
Gender
Undisclosed
HSC
N/A
@Troll - a '1' or '0' does not take as much memory as a 'M' or 'F' if you are storing it correctly. Boolean = two values only, pretty sure there are more than two types of characters :p

@MrBrightside
There's an extensive discussion here, I'd look at OMG Ponies' answer.
http://stackoverflow.com/questions/4175878/storing-sex-gender-in-database

IMO a strange question to have in a HSC exam.
yeah, That's the only reason why my teacher and friend said that character is a better choice, otherwise it would be sexist, as only having IsMale? [Yes or No] As opposed to, Gender? (M or F). which are characters and are moving away from the "boolean" logic.
 

hscishard

Active Member
Joined
Aug 4, 2009
Messages
2,033
Location
study room...maybe
Gender
Male
HSC
2011
What if, you made a drop down list with two values, Male and Female. Is that still considered as Boolean as it's either one or the other.
No, because you're using character to make the entities in drop down box. The drop down box is like just entering characters with your mouse
Initially I went with boolean, but character is most suitable as your field name for boolean would've been like "Male?"/"Female?" whereas for character it's "Gender/Sex", which is much better.

Was this a hsc exam question? Think i did it in a trial
 
Last edited:

MrBrightside

Brightest Member
Joined
Jan 18, 2010
Messages
2,033
Gender
Undisclosed
HSC
N/A
No, because you're using character to make the entities in drop down box. The drop down box is like just entering characters with your mouse
Initially I went with boolean, but character is most suitable as your field name for boolean would've been like "Male?"/"Female?" whereas for character it's "Gender/Sex", which is much better.

Was this a hsc exam question? Think i did it in a trial
Yeah was in the trial. I understand it now. Thank you.
 

kneehigh

New Member
Joined
Sep 21, 2011
Messages
2
Gender
Undisclosed
HSC
1998
Boolean is incorrect because it can only store 2 values - gender is now recognised as having more than two values , the Aust Govt recognises 3 M, F & Transgendered & some companies (eg Telstra) accept 5 values M, F, T, MasF, FasM
 

Scover

New Member
Joined
Feb 20, 2024
Messages
1
Gender
Undisclosed
HSC
N/A
I think we are missing a crucial advantage of the boolean data type.
If we use a character, we're allowing invalid value such as 'K' or '@'. The domain of the type does not match the semantical domain of the attribute.
A boolean doesn't have this problem, but considering the aforementioned issues, the best solution is probably a custom sum type.
 

wizzkids

Active Member
Joined
Jul 13, 2016
Messages
262
Gender
Undisclosed
HSC
1998
Everyone's talking about the efficiency of storing the information, but nobody is talking about the efficiency of retrieving and displaying the information.
Think about the extra coding if this field is stored as Boolean type (0 or 1).
Then you have to use extra CPU time to convert what character is represented by a 1 and what character is represented by a 0.
Save yourself (and the computer) the trouble and just store it as CHAR.
(C) is definitely the best answer.

[I agree with @kneehigh, CHAR also allows you to store LGBTQA or any other CHAR that political rectitude requires.]
 
Joined
Sep 4, 2023
Messages
49
Gender
Male
HSC
2024
While much attention is given to the efficiency of storing information, there's a glaring oversight regarding the efficiency of retrieving and displaying that data. Consider the additional coding required if this field were stored as a Boolean type, necessitating extra CPU time to decipher which character corresponds to 1 and which to 0. Simplify the process and save computational resources by opting to store the data as CHAR.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top