Share via


Relationships 物件 (TMSL)

適用于:SQL Server 2016 和更新版本的 Analysis Services Azure Analysis Services Fabric/Power BI Premium

定義來源和目標資料表之間的關聯性,並能夠指定基數,以及查詢和安全性篩選的方向。

物件定義

所有物件都有一組通用的屬性,包括名稱、類型、描述、屬性集合和批註。 關聯 性物件也有下列屬性。

isActive
布林值,指出關聯性是否標示為 [作用中] 或 [非作用中]。 使用中的關聯性會自動用於資料表之間的篩選。 非使用中關聯性可搭配 USERELATIONSHIP 函式用於 DAX 計算。

**crossFilteringBehavior ** 指出關聯性如何影響資料的篩選。 有效值為:

  • OneDirection (1) - 關聯性結尾中選取的資料列會自動篩選關聯性結尾中資料表的掃描。

  • BothDirections (2) - 關聯性任一端的篩選會自動篩選另一個資料表。

  • 自動 (3) - 引擎會分析關聯性,並使用啟發學習法選擇其中一個行為。

joinOnDateBehavior
在聯結兩個日期時間資料行時,指出要聯結日期與時間部分,或只有日期部分。

  • DateAndTime (1) - 聯結兩個日期時間資料行時,聯結日期和時間部分。

  • DatePartOnly (2) - 聯結兩個日期時間資料行時,僅聯結日期部分。

relyOnReferentialIntegrity
未使用。保留供日後使用。

securityFilteringBehavior
列舉,指出評估資料列層級安全性運算式時,關聯性如何影響資料的篩選。 下列是有效值:

  • OneDirection (1) - 關聯性結尾中選取的資料列會自動篩選關聯性結尾中資料表的掃描。

  • BothDirections (2) - 關聯性任一端的篩選會自動篩選另一個資料表。

使用方式

關聯性物件用於 Alter 命令 (TMSL) Create 命令 (TMSL) CreateOrReplace 命令 (TMSL) ,以及 Delete 命令 (TMSL)

建立、取代或改變關聯性物件時,請指定物件定義的所有讀寫屬性。 省略讀寫屬性會被視為刪除。

完整語法

以下是關聯性物件的架構表示。

"relationships": {  
          "type": "array",  
          "items": {  
            "anyOf": [  
              {  
                "description": "SingleColumnRelationship object of Tabular Object Model (TOM)",  
                "type": "object",  
                "properties": {  
                  "name": {  
                    "type": "string"  
                  },  
                  "isActive": {  
                    "type": "boolean"  
                  },  
                  "type": {  
                    "enum": [  
                      "singleColumn"  
                    ]  
                  },  
                  "crossFilteringBehavior": {  
                    "enum": [  
                      "oneDirection",  
                      "bothDirections",  
                      "automatic"  
                    ]  
                  },  
                  "joinOnDateBehavior": {  
                    "enum": [  
                      "dateAndTime",  
                      "datePartOnly"  
                    ]  
                  },  
                  "relyOnReferentialIntegrity": {  
                    "type": "boolean"  
                  },  
                  "securityFilteringBehavior": {  
                    "enum": [  
                      "oneDirection",  
                      "bothDirections"  
                    ]  
                  },  
                  "fromCardinality": {  
                    "enum": [  
                      "none",  
                      "one",  
                      "many"  
                    ]  
                  },  
                  "toCardinality": {  
                    "enum": [  
                      "none",  
                      "one",  
                      "many"  
                    ]  
                  },  
                  "fromColumn": {  
                    "type": "string"  
                  },  
                  "fromTable": {  
                    "type": "string"  
                  },  
                  "toColumn": {  
                    "type": "string"  
                  },  
                  "toTable": {  
                    "type": "string"  
                  },  
                  "annotations": {  
                    "type": "array",  
                    "items": {  
                      "description": "Annotation object of Tabular Object Model (TOM)",  
                      "type": "object",  
                      "properties": {  
                        "name": {  
                          "type": "string"  
                        },  
                        "value": {  
                          "anyOf": [  
                            {  
                              "type": "string"  
                            },  
                            {  
                              "type": "array",  
                              "items": {  
                                "type": "string"  
                              }  
                            }  
                          ]  
                        }  
                      },  
                      "additionalProperties": false  
                    }  
                  }  
                },  
                "additionalProperties": false  
              }  
            ]  
          }  
        }