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

# Part Numbers

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

## Introduction to the Part\_Numbers Table

The part\_numbers table is designed to store and manage information about specific part numbers within the Serial application. This table plays a crucial role in the system by linking part numbers to companies and components, while also tracking their status and associated metadata.

## Table Structure

The part\_numbers table is structured to provide comprehensive information about each part number. Here's a detailed breakdown of its columns:

| Column Name            | Data Type                | Constraints           | Description                                           |
| ---------------------- | ------------------------ | --------------------- | ----------------------------------------------------- |
| id                     | uuid                     | primary key           | Unique identifier for each part number entry          |
| company\_id            | uuid                     | foreign key, not null | Reference to the company associated with this part    |
| pn                     | text                     | not null              | The actual part number identifier                     |
| is\_active             | boolean                  | not null              | Indicates whether the part number is currently active |
| created\_at            | timestamp with time zone | not null              | Timestamp of when the entry was created               |
| last\_edited\_at       | timestamp with time zone | not null              | Timestamp of the last edit to this entry              |
| last\_edited\_user\_id | text                     | foreign key, nullable | Reference to the user who last edited this entry      |
| description            | text                     | nullable              | Optional description of the part number               |
| component\_id          | uuid                     | foreign key, nullable | Reference to the associated component                 |
| metadata               | jsonb                    | nullable              | Custom metadata stored in JSON format                 |

## Usage and Functionality

The part\_numbers table is designed to be a central repository for part number information within the Serial application. Here are some key points about its usage:

1. **Company and Component Association**: Each part number is linked to a specific company and can be associated with a component, allowing for organized tracking of parts across the system.

2. **Status Tracking**: The `is_active` field enables easy filtering of current and discontinued part numbers, facilitating inventory management and historical record-keeping.

3. **Flexible Metadata Storage**: The `metadata` column, using JSONB format, allows for storing additional custom information about part numbers without requiring schema changes.

4. **Edit History**: By tracking creation and last edit times, as well as the user who made the last edit, the table provides an audit trail for part number modifications.

## Notes

* The part\_numbers table is referenced by the unique\_identifiers table, indicating its role in tracking individual instances or units of parts.

* Example of querying active part numbers for a specific component:

  ```sql
  SELECT pn, description, metadata
  FROM part_numbers
  WHERE component_id = '324da2e3-30c4-4512-a432-8593a52b2019'
    AND is_active = true;
  ```

* The table is used in various database functions, such as `part_numbers_propagate_new_data`, which suggests that changes to part numbers may trigger updates in related tables.

By leveraging the part\_numbers table, the Serial application provides a robust system for managing and tracking part numbers across different companies and components, enabling efficient inventory management and traceability throughout the manufacturing or assembly process.
