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

# Label Elements

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

## Introduction to the label\_elements Table

The label\_elements table is designed to store information about individual elements within label designs. This table plays a crucial role in the Serial application's labeling system by maintaining detailed data for various types of label components, such as text, images, barcodes, QR codes, and identifiers.

## Table Structure

The label\_elements table is structured to capture the diverse attributes of different label element types. Here's a detailed breakdown of its columns:

| Column Name       | Data Type   | Constraints                                                  | Description                                                     |
| ----------------- | ----------- | ------------------------------------------------------------ | --------------------------------------------------------------- |
| id                | uuid        | primary key                                                  | Unique identifier for each label element                        |
| label\_format\_id | uuid        | foreign key                                                  | References the associated label format                          |
| company\_id       | uuid        | foreign key                                                  | References the company owning the element                       |
| type              | varchar(50) | check ('BARCODE', 'QR\_CODE', 'IDENTIFIER', 'TEXT', 'IMAGE') | Type of the label element                                       |
| x                 | float       |                                                              | Horizontal position in mm (absolute position only)              |
| y                 | float       |                                                              | Vertical position in mm (absolute position only)                |
| text              | text        |                                                              | Content for TextElement                                         |
| font\_size        | float       |                                                              | Font size for TextElement and IdentifierElement                 |
| bold              | boolean     |                                                              | Bold style for TextElement                                      |
| italic            | boolean     |                                                              | Italic style for TextElement                                    |
| underline         | boolean     |                                                              | Underline style for TextElement                                 |
| file\_id          | uuid        |                                                              | References the associated file for ImageElement                 |
| width             | float       |                                                              | Width in mm for ImageElement, BarcodeElement, and QrCodeElement |
| height            | float       |                                                              | Height in mm for BarcodeElement                                 |

## Usage and Functionality

The label\_elements table is designed to be flexible and accommodate various types of label elements. Here are some key points about its usage:

1. **Element Type Diversity**: The table supports multiple element types (Text, Image, Barcode, QR Code, Identifier) through the 'type' column, allowing for versatile label designs.

2. **Position and Sizing**: The 'x' and 'y' columns define the element's position on the label, while 'width' and 'height' specify dimensions for applicable element types.

3. **Text Formatting**: For text elements, the table stores formatting information such as font size, bold, italic, and underline styles.

4. **Company-Specific Data**: The 'company\_id' column ensures that label elements are associated with specific companies, supporting multi-tenant functionality.

## Notes

* The LabelElementType enum in TypeScript corresponds to the 'type' column in this table:

  ```typescript
  export enum LabelElementType {
    Barcode = "BARCODE",
    QRCode = "QR_CODE",
    Identifier = "IDENTIFIER",
    Text = "TEXT",
    Image = "IMAGE",
  }
  ```

* The label\_elements table works in conjunction with the label\_formats table to create complete label designs.

By leveraging the label\_elements table, the Serial application can store and manage detailed information about various components of label designs, enabling flexible and customizable label creation for different companies and use cases.
