---
title: "Lusid.Relationship.Definition"
slug: "lusidrelationshipdefinition"
updated: 2024-08-21T12:31:15Z
published: 2024-08-21T12:31:15Z
canonical: "support.lusid.com/lusidrelationshipdefinition"
---

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

# Lusid.Relationship.Definition

| **Type** | **Read/write** | **Author** | **Availability** |
| --- | --- | --- | --- |
| [Data provider](/v1/docs/what-are-a-data-provider-and-a-direct-provider) | Read | Finbourne | Provided with LUSID |

The `Lusid.Relationship.Definition` provider enables you to write a [Luminesce SQL query](/v1/docs/understanding-the-luminesce-sql-query-syntax) that retrieves [relationship types](/v1/docs/creating-relationships-between-certain-types-of-entity#creating-a-relationship-type) defined in LUSID.

> [!NOTE]
> **Note:**
> 
> The LUSID user running the query must have sufficient [access control permissions](/v1/docs/creating-policies-to-control-access-to-providers-for-different-luminesce-end-users) to both use the provider *and* read relationship type data stored in LUSID. This should automatically be the case if you are the domain owner.

**See also:** [Lusid.Relationship.Definition.Writer](/v1/docs/lusidrelationshipdefinitionwriter)

## Basic usage

```sql
select * from Lusid.Relationship.Definition
```

## Query parameters

`Lusid.Relationship.Definition` has parameters that help you to filter or refine a query.

To list available parameters, their data types, default values, and an explanation for each, run the following query using a [suitable tool](/v1/docs/what-tools-are-available-to-write-luminesce-queries):

```sql
select FieldName, DataType, ParamDefaultValue, Description from Sys.Field where TableName = 'Lusid.Relationship.Definition' and FieldType = 'Parameter';
```

## Data fields

By default, `Lusid.Relationship.Definition` returns a table of data populated with particular fields (columns). You can return a subset of these fields.

To list all fields available to return, their data types, whether fields are considered 'main', and an explanation for each, run the following query using a [suitable tool](/v1/docs/what-tools-are-available-to-write-luminesce-queries):

```sql
select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Lusid.Relationship.Definition' and FieldType = 'Column';
```

> [!NOTE]
> **Note:**
> 
> Fields marked 'main' are returned by queries that use a caret character, for example `select ^ from Lusid.Relationship.Definition`.

## Examples

> [!NOTE]
> **Note**:
> 
> For more examples, try the [Luminesce Github repo](https://github.com/finbourne/luminesce-examples/tree/master/examples).

### Example 1: Retrieve all relationship types

```sql
select * from Lusid.Relationship.Definition;
```

### Example 2: Retrieve all relationship types for a particular entity type

```sql
select * from Lusid.Relationship.Definition where SourceEntityType = 'Portfolio' or TargetEntityType = 'Portfolio'
```

### Example 3: Retrieve time-variant relationship types for particular entity types

```sql
select * 
from Lusid.Relationship.Definition 
where SourceEntityType in ('Portfolio', 'PortfolioGroup', 'LegalEntity', 'Instrument') 
  and Lifetime = 'TimeVariant'
  and RelationshipCardinality = 'ManyToMany'
limit 20;
```
