# Relationships

In Euno, the data model is made up of resources, each identified with a [Universal Resource Identifier](https://docs.euno.ai/developer-reference/technical-concepts/universal-resource-identifier-uri). Between these resources there are relationships.

These relationships form the foundation of Euno’s graph-based understanding of the data stack. There are five primary types of relationships:

### 1. Dependency

A dependency relationship exists when one resource relies on another. For example, a database view created by joining three tables will have three dependency relationships pointing from the view to each table.

If resource A depends on resource B, A is said to be downstream of B, and B is upstream of A.

A single resource may have zero, one, or many dependencies—technically a many-to-many relationship.

**Examples of using upstream and downstream queries:**

* To find the upstream of a resource:\
  `has upstream(uri="<resource-uri>")`
* To find the downstream of a resource:\
  `has downstream(uri="<resource-uri>")`

**Column-Level Dependencies**

Euno also supports fine-grained, column-level dependency tracking using the attributes `upstream_fields` and `downstream_fields`.\
These relationships capture dependencies between individual fields (such as columns, measures, or dimensions), or between fields and visualizations (such as Tableau views or Looker Looks).

**For instance:**

* A column in a table used in a Tableau view would create a dependency from the view to the column.
* A measure in a Looker Look based on multiple columns would be downstream of those columns.

**Examples of using `upstream_fields` and `downstream_fields`:**

* To find the visualizations in Tableau that use a specific field:\
  `type="tableau_view" and has upstream_fields(uri="<resource-uri>")`
* To find all the fields used in a Tableau view:\
  `type="tableau_field" and has downstream_fields(uri="<resource-uri>")`

**Note:** If a resource has both column-level lineage and regular lineage, and you want to return all relevant resources, you need to include both types of queries. For example:\
`has downstream_fields(uri="<resource-uri>") or has downstream(uri="<resource-uri>")`

**Statement-level dependencies for table resources**

For SQL-based table resources (for example, warehouse views), Euno also captures field dependencies that come from statement logic, not only projected fields. This means fields used in clauses like `JOIN`, `WHERE`, `GROUP BY`, `HAVING`, `QUALIFY`, and `ORDER BY` can appear in table-level `upstream_fields` relationships even when they are not selected in the final projection.

**Example**

If a view is defined as:

`SELECT order_id, customer_id FROM proj_sales.analytics.orders_raw WHERE order_status = 'COMPLETE'`

you may see a table-level upstream field relationship to the source column `orders_raw.order_status`, because that field is part of the statement logic.

### 2. Containment

A resource can be **contained** within another resource. For example, a column is contained in a table, and a table is contained in a schema.

When two resources, A and B, have a containment relationship such that A contains B, we say that A is the **parent** of B, and B is a **child** of A.

A resource can have zero, one, or many children, and zero or one parent. In technical terms, this is an optional many-to-one relationship.

**Examples using the containment relationship:**

* To find all the resources inside a workbook:\
  `has parent(type="tableau_workbook" and uri="<resource-uri>")`
* To return all the fields in a table:\
  `has parent(type="table" and uri="<resource-uri>")`

### 3. Defined-by

The `defined by` relationship links a resource to the entity that defines it.\
It is used when one resource determines the structure or existence of another.

For example, a Snowflake table created via a dbt model will have a `defined by` relationship pointing from the table to the dbt model.\
Conversely, the dbt model is considered the `definer` of the table.

It is possible for a resource to have multiple definers.

**Example:**

* To find the `dbt` resource that defines a specific table in the warehouse:\
  `type~"dbt" and has defined(type="table" and uri="<resource-uri>")` or `type~"dbt" and is definer of(type="table" and uri="<resource-uri>")`
* To find the `table` that is defined by a dbt model: `type="table" and has definer(type~"dbt" and uri="<resource-uri>")` or `type="table" and is defined by(type~"dbt" and uri="<resource-uri>")`

This relationship helps trace logical definitions across tools, and surfaces authoritative sources within your data stack.

### 4. Usage

A usage relationship exists when a user interacts with or uses a resource. This relationship tracks which users are accessing which resources, providing insights into resource utilization and user behavior.

If resource A (a user) uses resource B, A is said to be a **user** of B, and B is **used by** A.

A resource can be used by zero, one, or many users—technically a many-to-many relationship.

**Examples of using user and used queries:**

* To find all users of a specific resource:\
  `type="user" AND is user of(type='tableau_dashboard' AND uri="<resource-uri>")`
* To find all resources used by a specific user:\
  `type="tableau_view" AND is used by(name="john@doe.com")`

**Timeframe specification**: For usage relationships, you can limit results to a specific time period by adding `-Xd` parameters (where X is the number of days).

### 5. Membership

A membership relationship exists when a user or group is a member of another group or workspace. This relationship tracks organizational structure, access control, and group hierarchies.

If resource A (a user or group) is a member of resource B (a group or workspace), A is said to be a **member** of B, and B **has** A as a member.

A group or workspace can have zero, one, or many members—technically a many-to-many relationship. Groups can also be members of other groups, creating nested group hierarchies.

**Examples of using member and group queries:**

* To find all members of a specific group:\
  `has group(uri="<group-uri>")`
* To find all groups that a user is a member of:\
  `has member(uri="<user-uri>")`
* To find all members of a PowerBI workspace:\
  `has group(uri="<workspace-uri>")`

**Resource Types:**

* **user**: Represents an individual user in the system. Users can be members of groups and workspaces.
* **user\_group**: Represents a security group or organizational group. Groups can contain users and other groups as members.
* **powerbi\_workspace**: PowerBI workspaces can have users and groups as members, with role information (e.g., Admin, Member, Contributor).

**Role Information:**

When querying membership relationships with `extended_relationships=true`, the API returns role information for workspace memberships. For example, a user might be an "Admin" or "Member" of a PowerBI workspace.

### Summary of Resources and Possible Relationships

#### Lineage Relationships (`is upstream of`)

| Source Resource                                   | Relationship   | Target Resource                                                                                                                                                              |
| ------------------------------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| dbt\_seed, dbt\_source, dbt\_model, dbt\_snapshot | is upstream of | dbt\_model, dbt\_snapshot                                                                                                                                                    |
| dbt\_model                                        | is upstream of | dbt\_semantic\_model                                                                                                                                                         |
| dbt\_measure                                      | is upstream of | dbt\_metric                                                                                                                                                                  |
| dbt\_metric                                       | is upstream of | table, dbt\_metric, looker\_view                                                                                                                                             |
| table                                             | is upstream of | table, tableau\_published\_datasource, tableau\_embedded\_datasource, tableau\_custom\_sql, looker\_view, powerbi\_table, snowflake\_semantic\_view, omni\_view, omni\_model |
| tableau\_custom\_sql                              | is upstream of | tableau\_embedded\_datasource, tableau\_published\_datasource                                                                                                                |
| tableau\_published\_datasource                    | is upstream of | tableau\_embedded\_datasource                                                                                                                                                |
| tableau\_embedded\_datasource                     | is upstream of | tableau\_view                                                                                                                                                                |
| tableau\_view                                     | is upstream of | tableau\_dashboard                                                                                                                                                           |
| looker\_view                                      | is upstream of | looker\_view, looker\_explore                                                                                                                                                |
| looker\_explore                                   | is upstream of | looker\_view, looker\_explore, looker\_look, looker\_tile, looker\_dashboard                                                                                                 |
| looker\_tile                                      | is upstream of | looker\_dashboard                                                                                                                                                            |
| looker\_look                                      | is upstream of | looker\_dashboard                                                                                                                                                            |
| table                                             | is upstream of | hex\_project                                                                                                                                                                 |
| table                                             | is upstream of | databricks\_notebook                                                                                                                                                         |
| table                                             | is upstream of | powerbi\_dataflow                                                                                                                                                            |
| powerbi\_dataflow                                 | is upstream of | powerbi\_table                                                                                                                                                               |
| table                                             | is upstream of | powerbi\_table                                                                                                                                                               |
| powerbi\_table                                    | is upstream of | powerbi\_report, powerbi\_tile                                                                                                                                               |
| powerbi\_tile                                     | is upstream of | powerbi\_report                                                                                                                                                              |
| sigma\_workbook                                   | is upstream of | table                                                                                                                                                                        |
| hex\_semantic\_model                              | is upstream of | dbt\_semantic\_model                                                                                                                                                         |
| hex\_dimension                                    | is upstream of | dbt\_dimension                                                                                                                                                               |
| hex\_measure                                      | is upstream of | dbt\_metric                                                                                                                                                                  |
| omni\_model                                       | is upstream of | omni\_workbook                                                                                                                                                               |
| omni\_view                                        | is upstream of | omni\_query                                                                                                                                                                  |
| omni\_topic                                       | is upstream of | omni\_query                                                                                                                                                                  |

#### **Column-Level Lineage Relationships** (`is upstream_fields of`)

| Source Field     | Relationship           | Target Field                                                                                                                                                           |
| ---------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| column           | is upstream\_fields of | column, tableau\_field, hex\_project, databricks\_notebook, powerbi\_column, powerbi\_measure, snowflake\_dimension, snowflake\_metric, omni\_dimension, omni\_measure |
| tableau\_field   | is upstream\_fields of | tableau\_field, tableau\_view                                                                                                                                          |
| powerbi\_column  | is upstream\_fields of | powerbi\_measure, powerbi\_column, powerbi\_tile                                                                                                                       |
| powerbi\_measure | is upstream\_fields of | powerbi\_tile                                                                                                                                                          |
| hex\_dimension   | is upstream\_fields of | dbt\_dimension                                                                                                                                                         |
| hex\_measure     | is upstream\_fields of | dbt\_metric                                                                                                                                                            |
| omni\_dimension  | is upstream\_fields of | omni\_dimension, omni\_measure, omni\_query                                                                                                                            |
| omni\_measure    | is upstream\_fields of | omni\_dimension, omni\_measure, omni\_query                                                                                                                            |

#### Hierarchical Relationships (`has parent`)

| Child Resource                                                                                 | Relationship | Parent Resource                                                                                    |
| ---------------------------------------------------------------------------------------------- | ------------ | -------------------------------------------------------------------------------------------------- |
| column                                                                                         | has parent   | table, dbt\_source, dbt\_model, dbt\_snapshot                                                      |
| table                                                                                          | has parent   | database\_schema                                                                                   |
| database\_schema                                                                               | has parent   | database                                                                                           |
| database                                                                                       | has parent   | databricks\_workspace                                                                              |
| dbt\_dimension, dbt\_measure, dbt\_metric                                                      | has parent   | dbt\_model                                                                                         |
| dbt\_seed, dbt\_source, dbt\_model, dbt\_snapshot                                              | has parent   | dbt\_project                                                                                       |
| tableau\_published\_datasource, tableau\_workbook                                              | has parent   | tableau\_project                                                                                   |
| tableau\_embedded\_datasource, tableau\_dashboard, tableau\_view                               | has parent   | tableau\_workbook                                                                                  |
| tableau\_custom\_sql                                                                           | has parent   | tableau\_embedded\_datasource, tableau\_published\_datasource                                      |
| tableau\_field                                                                                 | has parent   | tableau\_embedded\_datasource, tableau\_published\_datasource, tableau\_custom\_sql, tableau\_view |
| looker\_dimension, looker\_measure                                                             | has parent   | looker\_view, looker\_explore, looker\_look, looker\_tile                                          |
| looker\_dashboard, looker\_look                                                                | has parent   | looker\_folder                                                                                     |
| looker\_tile                                                                                   | has parent   | looker\_dashboard                                                                                  |
| matillion\_pipeline                                                                            | has parent   | matillion\_project                                                                                 |
| powerbi\_report, powerbi\_dashboard, powerbi\_semantic\_model, powerbi\_dataflow, powerbi\_app | has parent   | powerbi\_workspace                                                                                 |
| powerbi\_table                                                                                 | has parent   | powerbi\_semantic\_model                                                                           |
| powerbi\_column, powerbi\_measure                                                              | has parent   | powerbi\_table                                                                                     |
| powerbi\_page                                                                                  | has parent   | powerbi\_report                                                                                    |
| powerbi\_tile                                                                                  | has parent   | powerbi\_page, powerbi\_dashboard, powerbi\_app                                                    |
| powerbi\_dashboard, powerbi\_report                                                            | has parent   | powerbi\_app                                                                                       |
| sigma\_workspace, sigma\_folder, sigma\_data\_model                                            | has parent   | sigma\_account                                                                                     |
| sigma\_folder                                                                                  | has parent   | sigma\_folder, sigma\_workspace                                                                    |
| sigma\_workbook                                                                                | has parent   | sigma\_folder, sigma\_workspace                                                                    |
| hex\_project, hex\_semantic\_project                                                           | has parent   | hex\_workspace                                                                                     |
| databricks\_notebook                                                                           | has parent   | databricks\_workspace                                                                              |
| hex\_semantic\_model                                                                           | has parent   | hex\_semantic\_project                                                                             |
| hex\_dimension, hex\_measure                                                                   | has parent   | hex\_semantic\_model                                                                               |
| snowflake\_dimension, snowflake\_metric                                                        | has parent   | snowflake\_semantic\_view                                                                          |
| omni\_folder, omni\_model                                                                      | has parent   | omni\_account                                                                                      |
| omni\_folder, omni\_workbook                                                                   | has parent   | omni\_folder                                                                                       |
| omni\_view, omni\_topic                                                                        | has parent   | omni\_model                                                                                        |
| omni\_dimension, omni\_measure                                                                 | has parent   | omni\_view, omni\_topic                                                                            |
| omni\_query, omni\_dashboard, omni\_view, omni\_topic                                          | has parent   | omni\_workbook                                                                                     |
| omni\_dimension                                                                                | has parent   | omni\_query                                                                                        |

#### **Definition Relationship** (`has definer`)

| Source Field | Relationship | Target Field                                                                                                      |
| ------------ | ------------ | ----------------------------------------------------------------------------------------------------------------- |
| table        | has definer  | dbt\_seed, dbt\_source, dbt\_model, dbt\_snapshot, fivetran\_connector, matillion\_pipeline, databricks\_notebook |

#### **Membership Relationships** (`has member` / `has group`)

| Source Resource                               | Relationship | Target Resource                               |
| --------------------------------------------- | ------------ | --------------------------------------------- |
| user, user\_group                             | has member   | user\_group, powerbi\_workspace, omni\_folder |
| user\_group, powerbi\_workspace, omni\_folder | has group    | user, user\_group                             |

**Note:**

* Groups can be members of other groups, creating nested hierarchies
* PowerBI workspaces can have both users and groups as members
* Omni folders can have both users and groups as members
* Membership relationships may include role information (e.g., Admin, Member) for workspace memberships

#### **Usage Relationships** (`is user of` / `is used by`)

| Source Resource                                                                                                                                                                                                                                     | Relationship | Target Resource                                                                                                                                                                                                                                     |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| user, user\_group                                                                                                                                                                                                                                   | is user of   | looker\_tile, looker\_explore, looker\_view, looker\_dimension, looker\_measure, tableau\_site, tableau\_dashboard, tableau\_view, powerbi\_account, powerbi\_report, powerbi\_dashboard, powerbi\_semantic\_model, omni\_workbook, omni\_dashboard |
| looker\_tile, looker\_explore, looker\_view, looker\_dimension, looker\_measure, tableau\_site, tableau\_dashboard, tableau\_view, powerbi\_account, powerbi\_report, powerbi\_dashboard, powerbi\_semantic\_model, omni\_workbook, omni\_dashboard | is used by   | user, user\_group                                                                                                                                                                                                                                   |

### Manually adding upstream dependencies in dbt

In addition to standard dbt-inferred relationships, Euno also supports custom dependency declarations via metadata annotations in dbt . Specifically, column-level `meta` fields in your `.yml` files can define additional upstream dependencies using the key:

```
euno.ai/additional_upstream_dependencies
```

This allows you to declare column-level relationships that are not inferable from SQL lineage. For example, create an upstream relationship from a column to a dbt metric.

**Accepted formats**

Both of the following are valid, add them to column definition in a `.yml` file:

```
meta:
  euno.ai/additional_upstream_depedencies:
    - metric.<metric_name>
    - model.<model_name>
```

```
meta:
  euno.ai/additional_upstream_depedencies: [metric.<metric_name>, model.<model_name>]
```

**Supported reference types**

Each value in the list should be a string referring to a valid dbt object. The following formats are supported:

| Object Type                    | Format Example                                            |
| ------------------------------ | --------------------------------------------------------- |
| dbt model/seed/source/snapshot | `model.<dbt_project_name>.<model_name>` or full unique ID |
| Metric (short form)            | `metric.<metric_name>`                                    |
| Metric (full unique\_id)       | `metric.<dbt_project_name>.<metric_name>`                 |

These references will be parsed and added as additional `table_dependencies` in the Euno knowledge graph.
