Are there reasons for not storing boolean values in SQL as bit data types without NULL? I see them often stored as integers without constraints to limit values to 0 and 1,
one reason is that people don't know about bit or think that y/n is simpler for formatting. other reason is that sometimes you think: hmm maybe over time this will be more than a bool field. and you make it int just in case.
you're not missing anything :)
We always store the data as a bit, it's small, and more importantly this is the case it is designed for.
We have had times where the end user was going to be working with the data directly, and to them, Yes/No or Y/N was more readable. In this case, we just created a view that reflected the friendlier data display.
Use Enum if you have more than two statuses.
Some reasons not to do so include:
Not all databases have a bit datatype so you use int instead to be able to use differnt backends
In some databases you cannot index a bit field.
And often what you have is not truly a true/false, yes/no with no other possibilities. For instance you might have a bit field for status meaning something like open or closed. But later you realize you need cancelled as a status as well.
what typically happens down the road is that someone wants to add also a maybe to yes and no, if you have a bit then now you have to change all your code to tinyint
if you had tinyint to begin with then you don't.....believe me this happens more than you think