As stated in the title, when designing databases, what is the preferred way to handle tables that have multiple columns that are just storing true / false values as just a single either or value (e.g. “Y/N: or “0/1”)? Likewise, are there some issues that might arise between different databases (e.g. Oracle and SQL Server) that might affect how the columns are handled?
Share
In
SQL Server, there isBITdatatype. You can store 0 or 1 there, compare the values but not runMINorMAX.In
Oracle, you just useNUMBERorCHAR(1).In
MySQLandPostgreSQLany datatype is implicitly convertible toBOOLEAN.Both systems support
BOOLEANdatatype which you can use as is, without the operators, in theWHEREorONclauses:, which is impossible in
SQL ServerandOracle(you need to have some kind or a predicate there).In
MySQL,BOOLEANis a synonym forTINYINT(1).In
PostgreSQLtoo (in terms of storage), but logically, it’s not implicitly convertible to any other type.