hi, just want to maek sure some thing.
so i have a table called user. in user table i want to add a field called date of birth. but i dont know which type to choice. it has int, varchar, date, datetime etc. but no date of birth.

do i just choice type date?

2nd question.
i also want a field called gender. so user can pick male or female. but i cant find the right type.

do i just choice boolean? 1 or maile and 0 for femail? but i want m for male and f for female

Recommended Answers

All 4 Replies

Yes, choosing the correct data type will help your database perform/scale better since you would not be assigning unecessary resources to store data. For example, in with regard to male and female, Boolean works well since you only have two choices. Boolean is generally used for true/false. So your field can be isMale? 0 is false, 1 is true.

Date will work for bday unless you need to be more precise.

Also keep an eye on the new argentine legislation where you are free to choose your gender as you like, and on the european discussion on transgender people. Might be that boolean is not the correct datatype for gender after all. In modern applications I'd recommend at least four choices: Female, Male, Trans, and Don't know.

Member Avatar

The difference between date and datetime is:
date: is used for values with a date part but no time part.
datetime: is used for values that contain both date and time parts.

For the gender you could use char. i.e. m for male, f for female, t for trans, X for don't know.

PS: Mark the post as solved if the answers provided have answered your question.

I would assume you know a little about Data types and i would suggest you read up on them. See these links here and here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.