Skip to main content

<relationship>

Defines a Business Intelligence cube relationship.

Details

To define a one-way relationship from one cube to another cube, you define a <relationship> element in the first cube.

To define a two-way relationship, you define two complementary <relationship> elements, one in each cube.

Important:

When you compile the cube classes, first compile the independent cube, which is the one that does not define a source property or source expression for the relationship. To control the compilation order, specify the DependsOn keyword in the class definition of the dependent cube.

Similarly, you must build the independent cube first. The DependsOn keyword has no effect on the order in which cubes are built.

The <relationship> element has the following attributes:

Attribute Purpose
name Name of the relationship. You use this logical name in MDX queries to use levels of the other cube. Typically this is the name of the other cube.
displayName, description, disabled See Common Attributes in a Cube.
relatedCube Logical name of the other cube.
inverse Value of the name attribute in the <relationship> element in the other cube.
cardinality Cardinality of the relationship.
sourceProperty, sourceExpression See Defining a One-Way Relationship and Defining a Two-Way Relationship in Defining Cube-Cube Relationships.
nullReplacement (Optional) Specifies the string to use as the member name if the source data for this relationship is null. For example, specify nullReplacement="No City". Specify this attribute within a <relationship> that specifies sourceProperty or sourceExpression
factName

(Optional) Name used (in the fact table) for the column that corresponds to this relationship. If this attribute is null, the system generates a name.

See the comments for factName for <measure>.

factNumber Internal ID assigned to this relationship. Required if namedFactNums is "true" for the cube.
linkClass, linkProperty Do not use. These are ignored.
dependsOn (Optional) Specifies the relationship on which this relationship has a dependency. Specify the logical name of the relationship. See Defining Dependencies Between Levels in Different Hierarchies. (Or, if the relationship depends upon a level, specify the MDX identifier of that level.)

This attribute is completely unrelated to the DependsOn compiler keyword.

Inverse and Cardinality Details

The following table summarizes which keywords to specify in each of scenarios:

Attribute In a One-way Relationship... In a Two-way Relationship...
inverse Omit this Specify this in both cubes
cardinality Use "one"
  • In the dependent cube, use "one"

  • In the independent cube, use "many"

sourceProperty or sourceExpression Specify as usual Applicable only in the dependent cube
factName Specify as usual Applicable only in the dependent cube; ignored in the other cube

Example

For examples, see Defining Cube-Cube Relationships.

FeedbackOpens in a new tab