Drupal - Which type to use for checkbox fields in hook_field_schema?

A tiny int would be most appropriate in my opinion:

$columns = array(
  'value' => array(
    'type' => 'int',
    'not null' => TRUE,
    'size' => 'tiny',
    'default' => 0,
  ),
);

A 'standard' int would be overkill for a field that will only ever hold a 0 or 1 value.

See the Data types docs for an overview of the different types available to you.


There is no boolean in the Drupal schema API so you just use a tiny int. Below is an example of a checkbox for a member where checked is "blocked" and unchecked is "in good standing":

  'status' => array(
    'description' => '0 = in good standing; 1 = blocked',
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 0,
  ),