Tables.GetRelationships
TableReturns the relationships among a set of tables structured like a navigation table.
Syntax
Tables.GetRelationships(tables as table, optional dataColumn as nullable text) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
tables | table | Yes | A set of tables with a navigation-table-like structure. |
dataColumn | text | No | The name of the column that contains the actual data tables. Defaults to the standard navigation table data column. |
Return Value
table — A table describing the relationships between the input tables.
Remarks
Tables.GetRelationships inspects a set of tables (typically a navigation table returned by a data source connector) and returns a table describing the relationships between them. The tables parameter is expected to have the structure of a navigation table — the kind of table returned by functions like Sql.Database, AnalysisServices.Database, or Excel.Workbook.
The optional dataColumn parameter specifies which column in the navigation table holds the actual table values. If omitted, the function uses the default navigation table data column.
This function is most useful when working programmatically with relational data sources where you need to discover foreign key relationships between tables — for example, when building a data model dynamically or validating relationship integrity.
Examples
Example 1: Discover relationships from a SQL Server database
let
NavTable = Sql.Database("localhost", "AdventureWorks"),
Relationships = Tables.GetRelationships(NavTable)
in
Relationships