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

# Table Relationships

> Manage joins, data models, columns, and entity relationships for tables

# Table Relationships

Manage join information, data models, column listings, and entity relationships for tables.

## Add Joins

`PUT /v1/tables/{id}/joins`

Record join information between this table and other tables.

**id** `string` *required*

UUID of the table.

**startDate** `string` *required*

Start date for the join period (ISO 8601 format). The period must fall within the past 30 days, ending today. In the examples, `{start_date}` stands for a date in this range, such as today's date.

**dayCount** `integer`

Number of days the join data covers.

**columnJoins** `array` *required*

Array of column join records.

**properties**

**columnName** `string` *required*

Name of the column in this table.

**joinedWith** `array` *required*

Array of joined column references.

**properties**

**fullyQualifiedName** `string` *required*

FQN of the joined column, for example `snowflake_prod.analytics.public.orders.customer_id`.

**joinCount** `integer` *required*

Number of times this join was observed.

## Set Data Model

`PUT /v1/tables/{id}/dataModel`

Set the data model (dbt or similar) associated with this table.

**id** `string` *required*

UUID of the table.

**modelType** `string` *required*

Type of data model: `DBT` or `DDL`.

**description** `string`

Description from the data model.

**sql** `string`

SQL query or transformation logic from the model.

**columns** `array`

Column descriptions and metadata from the data model. Each column needs a `name` and a `dataType`.

## Get Columns

`GET /v1/tables/{id}/columns`

Retrieve column information with optional pagination.

**id** `string` *required*

UUID of the table.

**limit** `integer` (default: 10)

Maximum number of columns to return.

**offset** `integer` (default: 0)

Offset for pagination.

```python PUT /v1/tables/{id}/joins theme={null}
from datetime import date

from metadata.sdk import configure, client

configure(
    host="https://your-company.open-metadata.org/api",
    jwt_token="your-jwt-token"
)

rest = client().ometa.client

table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"

# Add join information
rest.put(f"/tables/{table_id}/joins", json={
    "startDate": date.today().isoformat(),
    "dayCount": 1,
    "columnJoins": [
        {
            "columnName": "id",
            "joinedWith": [
                {
                    "fullyQualifiedName": "snowflake_prod.analytics.public.orders.customer_id",
                    "joinCount": 1542
                }
            ]
        }
    ]
})

# Set data model
rest.put(f"/tables/{table_id}/dataModel", json={
    "modelType": "DBT",
    "description": "Customer dimension table built from raw events",
    "sql": "SELECT id, name, email, created_at FROM raw.customers WHERE active = true",
    "columns": [
        {"name": "id", "dataType": "INT", "description": "Primary key from source"},
        {"name": "name", "dataType": "VARCHAR", "description": "Customer full name"},
        {"name": "email", "dataType": "VARCHAR", "description": "Verified email address"},
        {"name": "created_at", "dataType": "TIMESTAMP", "description": "First seen timestamp"}
    ]
})
```

```java PUT /v1/tables/{id}/joins theme={null}
import java.time.LocalDate;
import java.util.List;
import org.openmetadata.schema.type.ColumnJoin;
import org.openmetadata.schema.type.DataModel;
import org.openmetadata.schema.type.JoinedWith;
import org.openmetadata.schema.type.TableJoins;

// client is an initialized OpenMetadataClient.

String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";

// Add join information
TableJoins joins = new TableJoins()
    .withStartDate(LocalDate.now().toString())
    .withDayCount(1)
    .withColumnJoins(List.of(
        new ColumnJoin()
            .withColumnName("id")
            .withJoinedWith(List.of(
                new JoinedWith()
                    .withFullyQualifiedName("snowflake_prod.analytics.public.orders.customer_id")
                    .withJoinCount(1542)
            ))
    ));
client.tables().updateJoins(tableId, joins);

// Set data model
DataModel dataModel = new DataModel()
    .withModelType(DataModel.ModelType.DBT)
    .withDescription("Customer dimension table built from raw events")
    .withSql("SELECT id, name, email, created_at FROM raw.customers WHERE active = true");
client.tables().updateDataModel(tableId, dataModel);
```

```bash PUT /v1/tables/{id}/joins theme={null}
# Add join information
curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/joins" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "startDate": "{start_date}",
    "dayCount": 1,
    "columnJoins": [
      {
        "columnName": "agent_id",
        "joinedWith": [
          {
            "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_agent.agent_id",
            "joinCount": 1542
          }
        ]
      }
    ]
  }'

# Set data model
curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/dataModel" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "modelType": "DBT",
    "description": "Agent performance summary built from utilization detail tables",
    "sql": "SELECT agent_id, AVG(score) as performance_score FROM raw.agent_scores GROUP BY agent_id"
  }'

# Get columns with pagination
curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/columns?limit=10&offset=0" \
  -H "Authorization: Bearer {access_token}"
```

```json Response (Add Joins) theme={null}
{
  "startDate": "{start_date}",
  "dayCount": 1,
  "columnJoins": [
    {
      "columnName": "agent_id",
      "joinedWith": [
        {
          "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_agent.agent_id",
          "joinCount": 1542
        }
      ]
    }
  ]
}
```

***

## Returns

**Add joins** returns the join data associated with the table.

**Set data model** returns the updated table with data model attached.

**Get columns** returns a paginated list of column definitions.

***

## Error Handling

| Code | Error Type | Description |
| - | - | - |
| `401` | `UNAUTHORIZED` | Invalid or missing authentication token |
| `403` | `FORBIDDEN` | User lacks permission |
| `404` | `NOT_FOUND` | Table does not exist |
| `400` | `BAD_REQUEST` | Invalid join data or data model format |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.