> ## Documentation Index
> Fetch the complete documentation index at: https://docs.serial.okos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Checkboxes

> An in-depth look at the structure and purpose of the `checkboxes` table in the Serial database

## Introduction to the Checkboxes Table

The checkboxes table is designed to store checkbox data for various processes within the Serial application. This table plays a crucial role in capturing boolean-type responses and potentially contributing to pass/fail criteria in process workflows.

## Table Structure

The checkboxes table is structured to efficiently store and relate checkbox data to other entities in the system. Here's a detailed breakdown of its columns:

| Column Name            | Data Type                | Constraints             | Description                                           |
| ---------------------- | ------------------------ | ----------------------- | ----------------------------------------------------- |
| id                     | uuid                     | primary key, not null   | Unique identifier for each checkbox entry             |
| company\_id            | uuid                     | foreign key, not null   | Reference to the associated company                   |
| process\_entry\_id     | uuid                     | foreign key, not null   | Reference to the related process entry                |
| unique\_identifier\_id | uuid                     | foreign key, not null   | Reference to the associated unique identifier         |
| dataset\_id            | uuid                     | foreign key, not null   | Reference to the related dataset                      |
| prompt                 | text                     | not null                | The text prompt or question for the checkbox          |
| is\_pass               | boolean                  | nullable                | Indicates if the checkbox contributes to a pass state |
| is\_checked            | boolean                  | not null                | The state of the checkbox (checked or unchecked)      |
| created\_at            | timestamp with time zone | not null, default now() | Timestamp of when the checkbox entry was created      |

## Usage and Functionality

The checkboxes table is designed to be a flexible and integral part of data collection within processes. Here are some key points about its usage:

1. **Process Integration**: Each checkbox is associated with a specific process entry, allowing for detailed tracking of checkbox responses within the context of a particular process execution.

2. **Pass/Fail Criteria**: The `is_pass` column can be used to determine whether a checked or unchecked state contributes to the overall pass/fail status of a process or step.

3. **Data Aggregation**: By linking checkboxes to datasets and unique identifiers, the system can aggregate and analyze checkbox data across multiple processes or entities.

## Notes

* Row-level security is enabled on the checkboxes table, ensuring data privacy and access control.

* Policies are in place to restrict insert and select operations based on the user's associated company ID:

  ```sql
  create policy "Insert - Data - SameCompany"
  on "public"."checkboxes"
  as permissive
  for insert
  to authenticated
  with check ((company_id IN ( SELECT privileges.company_id
     FROM privileges
    WHERE (privileges.supabase_uid = auth.user_id()))));

  create policy "Select - Data - SameCompany"
  on "public"."checkboxes"
  as permissive
  for select
  to authenticated
  using ((company_id IN ( SELECT privileges.company_id
     FROM privileges
  ```

* The table structure allows for efficient querying of checkbox data, enabling features like filtering process entries based on checkbox states or analyzing trends in checkbox responses over time.

By leveraging the checkboxes table, the Serial application can capture and manage boolean-type responses within processes, contributing to a flexible and powerful system for tracking and analyzing workflow data.
