Skip to main content

Working with Relationships

Data model relationships refer to associations established between different models, specifying how data in one table relates to data in another table.

Relationships enable efficient querying and analysis of interconnected data.

Create a relationship

Create a relationship from the connection process

As an additional step during the connection process, you can define relationships among selected tables.

define_relationship_1

Create a relationship from the Modeling page

  1. Go to the diagram of the model you want to create a relationship.

  2. Click the "+" icon next to the "Relationships" section.

    create_ref_2

  3. Define the following properties in a relationship:

    • From: Select the left side table and column of this relationship.
    • To: Select the right side table and column of this relationship.
    • Type: Select the type of relationship (Many-to-one, One-to-many, One-to-one).

    create_ref_3

  4. Click "Save" to create.

Relationship Limitations

When creating relationships between data models in Wren AI, the following situations are not allowed:

1. Self-Referential Relationship

A self-referential relationship is when a column within a model points back to the same model.

For example, in an Employee model, the reportsTo column may store the ID of another Employee, indicating the reporting structure within the organization.

Wren AI currently does not support creating such self-referential relationships, where a column in a model references the same model. This limitation prevents the direct modeling of hierarchical or recursive data structures within a single model.

2. Relationship Duplication

Wren AI does not permit the creation of duplicate relationships between the same pair of models using identical columns.

For instance, if a relationship already exists between the Order and Customer models using the customerID field, you cannot create another relationship using the same customerID field between these models.

This restriction ensures that each relationship remains unique, avoiding redundancy and potential confusion in model associations.

Update a relationship

To update relationship settings in a model:

  1. Click the "..." icon next to the relationship on the model diagram.

  2. Choose "Edit".

    update_ref_2

  3. You can edit the Type of this relationship.

    update_ref_3

Delete a relationship

To delete a relationship:

  1. Click the "..." icon next to the relationship on the model diagram.
  2. Choose "Delete".

delete_ref

Relationship information

You can hover over the relationship line between model diagrams to see the information on specific relationships.

ref_info

Remember to deploy your changes

Deploy

Please press the "Deploy" button on the navigation bar to synchronize any modifications in the Modeling page.

The navigation bar will show an Undeployed changes message if there are any new changes. undeployed

The navigation bar will show a synced message if all changes have been deployed. deployed