Introduction to the label_formats Table
The label_formats table is designed to store and manage information about label formats for components in the Serial application. This table plays a crucial role in the system by providing a centralized repository for label specifications, including dimensions, metadata, and XML representations of label designs.Table Structure
The label_formats table is structured to capture comprehensive details about each label format. Here’s a detailed breakdown of its columns:| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | Unique identifier for the label format |
| company_id | uuid | not null, foreign key | Reference to the company owning the label format |
| component_id | uuid | not null, foreign key | Reference to the component associated with the format |
| name | varchar(255) | not null | Name of the label format |
| width | float | not null | Width of the label in millimeters |
| height | float | not null | Height of the label in millimeters |
| displayed_size_unit | varchar(10) | check (in (‘MM’, ‘IN’)) | Unit for displaying label size (MM or IN) |
| last_edited_at | timestamp | not null | Timestamp of the last edit |
| last_edited_by_user_id | uuid | not null, foreign key | Reference to the user who last edited the format |
| created_at | timestamp | not null | Timestamp of creation |
| created_by_user_id | uuid | not null, foreign key | Reference to the user who created the format |
| xml | text | XML representation of the label format | |
| xml_identifier | text | Identifier for the XML format |
Usage and Functionality
The label_formats table is designed to be a comprehensive storage solution for label specifications. Here are some key points about its usage:- Component-Specific Formats: Each label format is associated with a specific component, allowing for customized labeling solutions across different parts or products.
- Dimensional Flexibility: The table stores both the width and height of labels in millimeters, with an additional field for displaying sizes in either millimeters or inches, accommodating different measurement preferences.
- XML Support: The inclusion of XML fields allows for storing complex label designs that can be interpreted by label printing software or frontend rendering engines.
- Audit Trail: By tracking creation and last edit information, the table maintains a clear audit trail of changes to label formats.
- Security: Row-level security policies are implemented to ensure that users can only access and modify label formats associated with their company.
Notes
- The table has foreign key relationships with the companies, components, and users tables, ensuring data integrity and proper associations across the database.
- Row-level security is enabled on this table, which is crucial for maintaining data isolation between different companies using the system.
-
In the frontend application, this table is used in conjunction with the label_elements table to provide a complete label management system. Here’s an example of how label formats might be retrieved in the frontend:
- The XML fields (xml and xml_identifier) provide flexibility for storing and identifying complex label designs, potentially supporting integration with various label printing systems.

