# Binary Boolean (0/1)

Key: `representation.boolean.binary`

Boolean value represented as a binary digit: "0" for false, "1" for true. Common in CSV exports, database dumps, and flag columns. Transforms to DuckDB BOOLEAN type.

Page: <https://meridian.online/docs/projects/finetype/types/representation/boolean/binary>

Samples: `0`, `1`

## Background

### Origin

The Boolean data type is named after George Boole, who first defined an algebraic system of logic in the mid-19th century.[[1]](https://en.wikipedia.org/wiki/Boolean_data_type) A bit represents a logical state with one of two possible values.[[2]](https://en.wikipedia.org/wiki/Bit) The two values of a bit are most commonly represented as 1 and 0.[[2]](https://en.wikipedia.org/wiki/Bit) Claude E. Shannon first used the word bit in his 1948 paper A Mathematical Theory of Communication.[[2]](https://en.wikipedia.org/wiki/Bit) Shannon credited John W. Tukey, who had contracted binary digit to bit in a 1947 Bell Labs memo.[[2]](https://en.wikipedia.org/wiki/Bit)

In C, comparison operators return 0 for false and 1 for true.[[1]](https://en.wikipedia.org/wiki/Boolean_data_type) Standard C added a Boolean type, \_Bool, in C99, but Boolean values in C still behave as integers.[[1]](https://en.wikipedia.org/wiki/Boolean_data_type) The SQL:1999 standard introduced a BOOLEAN data type as an optional feature (T031).[[1]](https://en.wikipedia.org/wiki/Boolean_data_type) When a text export holds a column of only 0 and 1, it is worth asking whether it began life as a Boolean stored as a small integer. (Meridian's view)

### Use

SQL Server's bit data type is an integer data type that can take a value of 1, 0 or NULL.[[3]](https://learn.microsoft.com/en-us/sql/t-sql/data-types/bit-transact-sql) Microsoft's documentation says the bit data type can be used to store Boolean values.[[3]](https://learn.microsoft.com/en-us/sql/t-sql/data-types/bit-transact-sql) In SQL Server, converting to bit promotes any nonzero value to 1.[[3]](https://learn.microsoft.com/en-us/sql/t-sql/data-types/bit-transact-sql) In MySQL, BOOL and BOOLEAN are synonyms for TINYINT(1).[[4]](https://dev.mysql.com/doc/refman/8.4/en/numeric-type-syntax.html) MySQL treats the values TRUE and FALSE as merely aliases for 1 and 0.[[4]](https://dev.mysql.com/doc/refman/8.4/en/numeric-type-syntax.html) SQLite does not have a separate Boolean storage class and stores Boolean values as the integers 0 (false) and 1 (true).[[5]](https://www.sqlite.org/datatype3.html) SQLite recognises the keywords TRUE and FALSE as of version 3.23.0 (2018-04-02), as alternative spellings for the integer literals 1 and 0.[[5]](https://www.sqlite.org/datatype3.html) In Python, bool is a subclass of int, and in many numeric contexts False and True behave like the integers 0 and 1.[[6]](https://docs.python.org/3/library/stdtypes.html)

PostgreSQL's boolean input function accepts 1 for the true state and 0 for the false state, alongside true, yes, on, false, no and off.[[7]](https://www.postgresql.org/docs/current/datatype-boolean.html) The Data Package Table Schema lists 1 among the default trueValues and 0 among the default falseValues for a boolean field.[[8]](https://datapackage.org/standard/table-schema/) A column of nothing but 0 and 1 is not proof of a flag: a count, a rating or a category code can happen to hold only those two digits in a sample, so check the column's name and documentation before casting it to a boolean. (Meridian's view) Treat an empty cell as unknown rather than false, since a missing flag and a recorded 0 are different statements about the data. (Meridian's view)

## Sources

1. [Boolean data type](https://en.wikipedia.org/wiki/Boolean_data_type) — secondary source
2. [Bit - Wikipedia](https://en.wikipedia.org/wiki/Bit) — secondary source
3. [bit (Transact-SQL) - SQL Server \| Microsoft Learn](https://learn.microsoft.com/en-us/sql/t-sql/data-types/bit-transact-sql) — documentation
4. [MySQL :: MySQL 8.4 Reference Manual :: 13.1.1 Numeric Data Type Syntax](https://dev.mysql.com/doc/refman/8.4/en/numeric-type-syntax.html) — documentation
5. [Datatypes In SQLite](https://www.sqlite.org/datatype3.html) — documentation
6. [Built-in Types — Python 3.15.0 documentation](https://docs.python.org/3/library/stdtypes.html) — documentation
7. [PostgreSQL: Documentation: 18: 8.6. Boolean Type](https://www.postgresql.org/docs/current/datatype-boolean.html) — documentation
8. [Table Schema \| Data Package Standard](https://datapackage.org/standard/table-schema/) — standard
