Search code examples
mysqltypesbooleanprimitive

Boolean represented as text or number?


I am creating an application with three data types:

  • Number
  • Text
  • Date

The app is geared towards a non-technical user who would know what a date is, or what a number is (without caring/knowing if it's an int, decimal, float, etc.). My question is, which type do you think would seem the most 'intuitive' for a user to represent a boolean value, Number or Text?

I think Number is the correct answer technically (in sql I would store it as tinyint(1) DEFAULT NULL), but I'm not so sure if that is the easiest to understand for a non-technical user, who might think of a boolean as a "Yes" or "No" or a "True" or "False", both of which look like and sound like text.

Which data type would you classify a boolean in under these circumstances and why?


Solution

  • I also think that technically correct to use 1 or 0. But, given that the issue arose and came here, you probably care about accessibility. And so in this case, the text "Yes" and "No" is the most accessible of all that can be.