Add a relationship between tables

1. Overview

Relationships allow you to work with data from multiple data sources as if they had already been prepared into a single data cube for you. For example, with relationships defined, data from an Excel file and a SQL table can be selected together and automatically joined, even if the matching columns have different names.

You can use theRelationshipsdialog to review existing relationships and add new ones. These are used when selecting data in a metric set, or when creating a multi-level hierarchy.

Note
If there is no relationship defined, Dundas BI will guess the relationship when you use unrelated data in a metric set. You can then modify how the data was joined as shown inAutomatic joins and hierarchies.

2. Review existing relationships

Go to theExplorewindow, right-click on a table and chooseRelationships.

Select Relationships from the menu
Select Relationships from the menu

Note
For data cubes, you cannot define a relationship between its data and another data structure before combining its data with other data in a metric set, but you canedit the automatic joinafterward.

In theRelationshipsdialog, you will see a diagram displaying the existing relationships between that table and other tables/data structures.

Relationship between two tables
Relationship between two tables

Hover over or long-tap a node (circle) to view details about how it's related in a tooltip.

Hover over a node to view details
Hover over a node to view details

For each table node in the diagram, you can right-click (or long-tap) and chooseExpandto add all of the additional tables related to that table to the diagram. This allows you to explore and discover other relevant data that can be made available by the intermediate tables.

Relationship diagram after expanding the SalesOrderHeader table node
Relationship diagram after expanding the SalesOrderHeader table node

If needed, to view the relationships as a list, clickList view. TheCategorycolumn displaying in list view indicates how each relationship was created:

  • Nativerelationships are defined in the database (e.g., foreign keys).
  • System-defined关系是由邓达斯自动创建的BI prior to version 7.
  • User-definedrelationships were created by a Dundas BI user.

Return toDiagram view, then right-click a node and clickEditto see its details.

Note
Native relationships can only be modified in the source database.

3. Create a relationship

By creating a relationship ahead of time, you can define how two tables are related rather than allow Dundas BI to choose for you when you or others drag data from those tables onto one metric set.

Start in theRelationshipsdialog opened for one of the tables as described above, and clickAdd relationship. TheSet Up a Relationshipdialog is displayed.

Enter aNamefor the relationship.

Add a relationship between category and subcategory
Add a relationship between category and subcategory

UnderTarget Structure, find the data connector containing related data and select the related table. This data can be from a different data source.

Match elements from each structure by dragging one from the left underSource Elementsto the equivalent underReferenced Elements.

Match category relationship elements
Match category relationship elements

Click the submit button at the bottom of the dialog to add the relationship.

The new relationship will now be add to the diagram in theRelationshipsdialog as a user-defined relationship.

A user-defined relationship is added to the diagram
A user-defined relationship is added to the diagram

4. Using relationships

Relationships are used when selecting data from different tables and structures in a metric set, whether in the full-screen metric set editor or when working with metric sets on a dashboard or another view. They are also used when creating ahierarchythat contains multiple levels.

To demonstrate, we will create a single metric set as shown below based on a database table and two Excel spreadsheet files, after relationships have been defined.

In a new dashboard, drag a column from the table(产品ion].[ProductCategory]to the canvas.

Creating a table with categories from a database
Creating a table with categories from a database

Drag a column from an Excel sheet toRowsin the Data Analysis Panel.

Adding Excel subcategories to the table
Adding Excel subcategories to the table

Drag a column containing additional details from a different Excel data connector.

Add Excel details to the table
Add Excel details to the table

In the background, Dundas BI created automatic joins between the three tables based on the created relationships. TheAutomatic joins and hierarchiesarticle shows you how you can view and edit the automatic joins, along with more examples of combining data.

You can also view these joins bypromoting the auto-generated metric setif applicable, and then promoting the auto-generated source data cube behind the metric set. Edit this data cube (as aDeveloper user) to see the join transforms.

Resulting data cube
Resulting data cube

5.另请参阅

Dundas Data Visualization, Inc.
400-15 Gervais Drive
Toronto, ON, Canada
M3C 1Y8

North America: 1.800.463.1492
国际:1.416.467.5100

Dundas Support Hours:
Phone: 9am-6pm, ET, Mon-Fri
Email: 7am-6pm, ET, Mon-Fri