Switch to: V9V8V7V6V5

Boolean (BIT) Field

Bit fields are used to reduce memory consumption when requirements of integer variables will always have low values. Some systems store integer values within two bytes (16-bits) of memory, even though only one or two bits are actually used. Boolean fields are much more memory efficient.

Range of Type

This type of field can contains Values 0 or 1, which you can interpret as True | False, Yes | No or On | Off as required.

Storage

This range of values can be stored in ONE BIT as either value of 0 or 1. In usage, this value can be interpreted in any binary way.

Valentina DB vs Other DBMS

Some other DBMS use either one byte on disk per Boolean field or they pack few bits into one byte until a table has anywhere from 1 to 8 Boolean fields. Beyond that, they start to use a second byte, and so on.

Valentina in contrast, always uses one bit on disk per field for its values. This is thanks to the format of field storage, with each field stored as separate logical file.

Flags

  • fNullable

This field can be declared as Nullable. In this case a special bitmap is associated with this field.

Nullable Boolean field is able to keep 3-state values: { NULL, True, False }.

  • fIndexed

Boolean field always have this flag ON. You cannot set it OFF. This is because storage of this field is such effective that there is no need for index at all.

Read Mode About Field Flags

Indexes

See description of the fIndexed flag above.

API

This field type is represented at the API level by VBoolean Class.

SQL

At SQL Level you can create such field using

CREATE TABLE T1( fldBoolean BOOLEAN );

You can search this field using comparison to TRUE/FALSE:

SELECT * FROM T1 WHERE fldBoolean = TRUE;