> ## 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.

# Work Instruction Blocks

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

## Introduction to the Work\_Instruction\_Blocks Table

The work\_instruction\_blocks table is designed to store individual blocks of work instructions associated with process steps. This table plays a crucial role in the Serial system by providing a flexible and structured way to represent various types of instructional content, such as text, images, videos, and more.

## Table Structure

The work\_instruction\_blocks table is structured to accommodate different types of content while maintaining relationships with processes and companies. Here's a detailed breakdown of its columns:

| Column Name       | Data Type | Constraints             | Description                                         |
| ----------------- | --------- | ----------------------- | --------------------------------------------------- |
| id                | uuid      | primary key             | Unique identifier for each work instruction block   |
| company\_id       | uuid      | foreign key, not null   | Reference to the company owning the block           |
| process\_step\_id | uuid      | foreign key, not null   | Reference to the associated process step            |
| order             | integer   | not null                | Order of the block within the process step          |
| type              | text      | not null                | Type of the work instruction block                  |
| file\_id          | uuid      |                         | Reference to an associated file (if applicable)     |
| content           | jsonb     |                         | JSON content of the block, structure varies by type |
| created\_at       | timestamp | not null, default now() | Timestamp of block creation                         |
| dataset\_ref\_1   | uuid      |                         | Reference to an associated dataset (if applicable)  |
| dataset\_ref\_2   | uuid      |                         | Reference to an associated dataset (if applicable)  |
| dataset\_ref\_3   | uuid      |                         | Reference to an associated dataset (if applicable)  |
| dataset\_ref\_4   | uuid      |                         | Reference to an associated dataset (if applicable)  |
| dataset\_ref\_5   | uuid      |                         | Reference to an associated dataset (if applicable)  |

## Usage and Functionality

The work\_instruction\_blocks table is designed to be flexible and extensible, accommodating various types of instructional content. Here are some key points about its usage:

1. **Block Types**: The table supports multiple block types, including Heading, Text, Image, Video, PDF, File, List, Table, Callout, Code, and Delimiter. Each type has its own structure within the content JSONB field.

2. **Content Storage**: The content column uses JSONB to store type-specific data. For example, a Heading block might include a 'text' field and a 'level' field, while an Image block might store 'file\_name' and 'height'.

3. **Ordering**: The 'order' column ensures that blocks can be displayed in the correct sequence within a process step, allowing for a logical flow of instructions.

4. **Dataset References**: The table includes five dataset reference columns, allowing blocks to be associated with up to five different datasets. This feature enables dynamic content based on dataset information.

## Notes

* The work\_instruction\_blocks table is closely related to the process\_steps table, with each block belonging to a specific step in a process.

* Here's an example of how a work instruction block might be represented in TypeScript:

  ```typescript
  interface ImageBlock extends BaseWorkInstructionBlock {
    type: WorkInstructionBlockType.Image;
    file_id: string;
    content: {
      file_name: string;
      height: number;
      caption?: string;
    };
  }
  ```

By leveraging the work\_instruction\_blocks table, the Serial application can create rich, interactive work instructions that combine various media types and data sources, enhancing the user experience in both the process builder and production environments.
