> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcollate.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Managing and Editing Table Constraints

> Learn how to view, edit, and manage table constraints in Collate to track relationships, enhance lineage, and support data governance.

# Table Constraints

Table constraints define the rules and relationships that apply to columns in a table — such as primary keys, foreign keys, and unique constraints. In Collate, these constraints are automatically captured during metadata ingestion and displayed on the table's detail page, giving you a clear picture of how your tables relate to one another.

Understanding table constraints helps with:

* **Data discovery:** Quickly see which columns are keys or references to other tables.
* **Lineage tracking:** Foreign key relationships feed into Collate's lineage graph.
* **Data governance:** Enforce and communicate structural rules about your data.

## Viewing Table Constraints

Once metadata ingestion is complete:

1. Open the table you want to inspect.
2. Click the **Columns** tab (selected by default).
3. Scroll down the right panel to find the **Table Constraints** section.

   <img src="https://mintcdn.com/collatedocs/LUQwLPA4Y6ndbf92/public/images/ai-2.0/data-discovery/table-constraints.png?fit=max&auto=format&n=LUQwLPA4Y6ndbf92&q=85&s=16cd601efa08d9a5dfb850c07b83b016" alt="Table Constraints in the right panel" width="2804" height="1564" data-path="public/images/ai-2.0/data-discovery/table-constraints.png" />

Each constraint is shown with an icon indicating its type — for example, a key icon (🔑) indicates a primary key column. Foreign key constraints also show the referenced table and column, making it easy to trace relationships across your data.

## Editing Table Constraints

You can manually add or modify table constraints directly from the Collate UI if they were not captured during ingestion or need correction.

### Before You Begin

Make sure you have **Edit** permissions on the table. If the edit option is grayed out, contact your Collate administrator to request the appropriate role.

### Steps to Edit

1. Navigate to the table's detail page and open the **Columns** tab.

2. Click the **Edit** (pencil) icon next to the **Table Constraints** section in the right panel.

   <img src="https://mintcdn.com/collatedocs/-lrw-eBbNcdV_Qdw/public/images/ai-2.0/data-discovery/edit-table-constraint.png?fit=max&auto=format&n=-lrw-eBbNcdV_Qdw&q=85&s=24016826883eb5cb10016f47e1d77aa6" alt="Edit Table Constraints" width="2768" height="1618" data-path="public/images/ai-2.0/data-discovery/edit-table-constraint.png" />

3. An editing panel appears where you can add, update, or remove constraints. For each constraint, select the **Constraint Type** and the **Column(s)** it applies to. Collate supports the following constraint types:

   * **Primary Key** — Identifies each row in the table uniquely. Select one or more columns that form the primary key.
   * **Foreign Key** — Links a column in this table to a column in another table. After selecting the columns, specify the referenced table and column, and choose the relationship type (One to One, One to Many, Many to One, Many to Many).
   * **Unique** — Ensures all values in the selected column(s) are distinct.
   * **Dist Key** — Marks the column used to distribute rows across nodes (common in Redshift and Snowflake).
   * **Sort Key** — Marks the column used to sort rows on disk for faster queries (common in Redshift and Snowflake).
   * **Cluster Key** — Marks the column used for clustering (common in BigQuery and Snowflake).

   <img src="https://mintcdn.com/collatedocs/-lrw-eBbNcdV_Qdw/public/images/ai-2.0/data-discovery/add-modify-constraints.png?fit=max&auto=format&n=-lrw-eBbNcdV_Qdw&q=85&s=b84ac9741a564f221caff801300eb7a7" alt="Modify Constraints" width="1630" height="994" data-path="public/images/ai-2.0/data-discovery/add-modify-constraints.png" />

4. Save your changes.

If the editing option is unavailable, it may indicate insufficient permissions or that the feature requires a newer version of Collate. In that case, consult your administrator.
