# Relation Editor

## Overview

The **Relation Editor** is a graphical interface that allows the creation of [relations](/reference/servoy-developer/solution-explorer/all-solutions/active-solution/relations/relation.md) between two tables at Servoy level, not database level, which can be used as a filtered data source in multiple places i.e. show a related form in a tab using the [Tabpanel component](/reference/servoyextensions/ui-components/form-containers/tabpanel.md)

<figure><img src="/files/JVAYqZarO1B4hgQCv3sK" alt=""><figcaption><p>Sample of relation in editor</p></figcaption></figure>

## Sections

### Name & Tables Selection

Source and Destination tables can be any Database Table, Database View, or In-Memory Table, View Foundsets can be used only as Destination, and the same table can be used as Source and Destination as well. Table selection can be done by entering manually the database name and table name or using the [Datasource Selection Wizard](/reference/servoy-developer/object-editors/datasource-selection-wizard.md).

Once Source and Destination are selected the relation name is automatically generated but it can be edited.

### Fields Selection

There is a list of empty rows where you can select any field from the Source table to match a field on the Destination table indicating what type of operator should be used to compare them, the two fields on a single row must be the same type.

A Source field can also be a scope variable and the variable type must also match the type of the Destination field.

The available operators are:

| Operator | Description                                                                                                                        |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| =        | <p>Equal. This is the default operator.<br>This is also an <code>IN</code> operator when the Source field is an array variable</p> |
| >        | Greater than                                                                                                                       |
| <        | Less than                                                                                                                          |
| >=       | Greater or equal than                                                                                                              |
| <=       | Less or equal than                                                                                                                 |
| !=       | Not equal                                                                                                                          |
| like     | Contains                                                                                                                           |
| not like | Not Contains                                                                                                                       |

For each operator, there are some modifiers that can be applied:

| Modifier         | Description                                                                                                                  |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| or-is-null       | The Destination field can also be `null` besides the operator specified                                                      |
| case-insensitive | When the fields are text, the comparison is done without considering uppercase or lowercase                                  |
| remove-when-null | When the Source field is a scope variable and it's `null` the criterion is removed from the relation when querying the table |

### Options

There are a number of options that can change the behavior of a relation and how Servoy handles records in either the Source or Destination table.

| Option                                          | Description                                                                                                                                                                             |
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Join type                                       | It can be either *inner join* or *left outer join*                                                                                                                                      |
| Initial sort                                    | Allows to define the default sorting used the first time the relation is created using the [Sorting Fields Wizard](/reference/servoy-developer/object-editors/sorting-fields-wizard.md) |
| Deprecated                                      | Flag to indicate that the relation should not be used                                                                                                                                   |
| Encapsulation                                   | Determine the scope of the relation: \_Publi\_c, *Hide in Scripting: Module Scope*, or *Module Scope*                                                                                   |
| Allow creation of related records               | Flag to indicate if new records can be added in the Destination table using the relation criteria                                                                                       |
| Allow parent delete when having related records | Flag to indicate if a record in the Source table can be deleted when there are still records in the Destination table that match the relation criteria                                  |
| Delete related records                          | Flag to indicate if all records in the Destination table that match the relation criteria must be deleted when a record in the Source table is deleted                                  |
| Comment                                         | Free text box to enter a comment about the relation                                                                                                                                     |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/servoy-developer/object-editors/relation-editor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
