Skip to main content
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 NameData TypeConstraintsDescription
iduuidprimary keyUnique identifier for each link
company_iduuidforeign key, not nullReferences the company owning the link
component_iduuidforeign key, not nullReferences the parent component
has_child_of_iduuidforeign key, not nullReferences the child component
process_iduuidforeign key, not nullReferences the process associated with the link
dataset_iduuidnullableReferences the dataset associated with the link, if any
data_key_iduuidforeign key, nullableReferences the data key associated with the link, if any
created_attimestamp with time zonenot null, default now()Timestamp of link creation
is_activebooleannot null, default trueIndicates 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:
  1. 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.
  2. 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.
  3. 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.
  4. Active Status Tracking: The is_active column 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:
    const { data, error } = await supabase.from("component_links").insert({
      company_id: "cc1ed015-6c6b-426a-a806-19c500a00aba",
      component_id: "6df39f0a-b1dc-4786-abac-916ef2fcab1f",
      has_child_of_id: "6ed78908-4dea-421f-8550-9c781eec38a4",
      process_id: "14358e0a-5f93-429f-81b6-6930a9c4ee77",
      dataset_id: "9fd0a461-52fc-4ea5-b5fe-7e4f6c47509f",
    });
    
  • The data_key_id column allows for optional association with specific data keys, providing additional flexibility in data management.
By leveraging the component_links table, the Serial application can maintain a comprehensive and flexible representation of component relationships throughout various manufacturing processes, enabling efficient tracking and analysis of product structures and assembly hierarchies.