Skip to main content

Introduction to the Components Table

The Components table is designed to store and manage information about various components associated with companies in the Serial system. This table plays a crucial role in organizing and tracking the status, type, and ownership of components within the application.

Table Structure

The Components table is structured to efficiently store essential information about each component. Here’s a detailed breakdown of its columns:
Column NameData TypeConstraintsDescription
iduuidprimary keyUnique identifier for each component
company_iduuidforeign keyReferences the company that owns the component
last_edited_user_iduuidforeign keyReferences the user who last edited the component
statustextCurrent status of the component
typetextType or category of the component
created_attimestampnot nullTimestamp of when the component was created
is_activebooleannot nullFlag indicating whether the component is active

Usage and Functionality

The Components table is designed to be a central repository for component information within the Serial application. Here are some key points about its usage:
  1. Company Association: Each component is linked to a specific company through the company_id foreign key, allowing for efficient organization and retrieval of company-specific components.
  2. Tracking Changes: The last_edited_user_id column helps maintain an audit trail by recording which user last modified the component’s information.
  3. Status and Type Management: The status and type columns allow for categorization and tracking of components throughout their lifecycle, enabling efficient filtering and reporting.
  4. Active/Inactive Flagging: The is_active boolean column provides a quick way to determine whether a component is currently in use or has been deprecated, without the need to delete records.

Notes

  • Foreign key relationships with the companies and users tables maintain data integrity and enable complex queries across related data.
  • Example usage in TypeScript:
    const newComponent = {
      id: uuid(),
      company_id: companyId,
      last_edited_user_id: currentUserId,
      status: "active",
      type: "hardware",
      created_at: new Date(),
      is_active: true,
    };
    await supabase.from("components").insert(newComponent);
    
  • When querying the Components table, it’s important to consider the is_active flag to ensure only relevant components are retrieved in most operations.
By leveraging the Components table, the Serial application can efficiently manage and track various components across different companies, providing a robust foundation for inventory management, component lifecycle tracking, and related functionalities within the system.