Introduction to the Component_Links Table
The component_links table is designed to establish hierarchical relationships between components in the Serial database. This table plays a crucial role in tracking the connections between parent and child components, associating them with specific processes and datasets.Table Structure
The component_links table is structured to efficiently represent component relationships and their associated data. Here’s a detailed breakdown of its columns:| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | Unique identifier for each link |
| company_id | uuid | foreign key, not null | References the company owning the link |
| component_id | uuid | foreign key, not null | References the parent component |
| has_child_of_id | uuid | foreign key, not null | References the child component |
| process_id | uuid | foreign key, not null | References the process associated with the link |
| dataset_id | uuid | nullable | References the dataset associated with the link, if any |
| data_key_id | uuid | foreign key, nullable | References the data key associated with the link, if any |
| created_at | timestamp with time zone | not null, default now() | Timestamp of link creation |
| is_active | boolean | not null, default true | Indicates whether the link is currently active |
Usage and Functionality
The component_links table is designed to be flexible and support complex component hierarchies. Here are some key points about its usage:- Hierarchical Component Relationships: The table allows for the creation of parent-child relationships between components, enabling the representation of complex product structures or assembly hierarchies.
- Process and Dataset Association: Each link is associated with a specific process, and optionally with a dataset, allowing for detailed tracking of component relationships within different manufacturing or assembly processes.
- Unique Constraint: The table enforces a unique constraint on the combination of (component_id, has_child_of_id, process_id, dataset_id), ensuring that no duplicate links are created for the same component relationship and process-dataset combination.
-
Active Status Tracking: The
is_activecolumn allows for soft deletion or deactivation of links without removing the historical data from the database.
Notes
- The table has a Row Level Security (RLS) policy that allows only ADMIN users to update rows for their respective companies, ensuring data integrity and access control.
-
Example of creating a new component link:
-
The
data_key_idcolumn allows for optional association with specific data keys, providing additional flexibility in data management.

