1

I am currently designing a WPF application using a SQLite database. As part of this form, users are asked whether they have any disabilities and can check a couple of options in a list, such as No disability, Leg problems, heart issues etc. This will all go into a database that has a Student table. Currently my Student table SQL code is as follows:

CREATE TABLE STUDENT(
    StudentID int(5),
    firstName string(256),
    ...,
    age int(3)
);

The issue I am having is not knowing how to store this in the database. I know SQLite does not support Boolean values as this was my initial idea. If the box was selected then the value would be set to True and vice versa. In the absence of Boolean values, how would I go about storing this data in a database?

Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54
Andy Orchard
  • 15
  • 1
  • 7

2 Answers2

2

You can store boolean value in int(1) where 0 represent false and 1 - true.

See Data types in SQLite documentation there is separate section 2.1 Boolean Datatype:

SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true).

Renatas M.
  • 11,694
  • 1
  • 43
  • 62
1

As you previously said, SQLite doesn't support BOOLEAN.

You have to store it as an INT.

1 will be TRUE

0 will be FALSE

SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true).

You can check the documentation here

Cesar
  • 453
  • 9
  • 21