Table of Contents generated with DocToc
A data model, or an associative relationship model, allows the creation of join or union relationships between data sets, and incorporates these relationships during chart creation. Compared with creating a fusion data set to establish a wide table, the data model has the following advantages:
HENGSHI SENSE 3.2 has enhanced data models in several ways, including:
At the same time, new concepts are introduced:
When a data set participates in the associative relationships of other model tables, its identity is "associated table," and within its own data model, its identity is "model table." When selecting a data set for charting, the entire data model with that data set as the model table is brought in.
Only supports building a data model with data sets under the same connection from the same source.
A chart can only use one data model and cannot chart across data models.
In the data model area, click a data set, and then drag a data set from the left-side list to it to pop up the Create New Relationship
dialogue. In the dialogue, you can set:
Association relationship refers to the way data sets are joined, including the following four types:
Some databases do not support full join due to their own limitations, such as MySQL 5, TiDB, etc. There will be prompts when creating the model.
Association conditions have two setting modes: Simple Condition
and Expression Condition
.
Simple conditions have two types of relationships between multiple conditions: Any Condition
(OR) and All Conditions
(AND).
Expression condition supports users to freely write association conditions, which can be field a > field b or like(field a, field b), as shown below:
Click an associative relationship icon, choose Edit
in the pop-up menu, and the Edit Relationship
page will appear. The Edit Relationship
page is exactly the same as the Create New Relationship
page.
Hover the mouse over any part of a data set to call out the append + icon, click this icon to expand the append data set area, and then drag a data set from the left-side list to append it:
Append principles are as follows:
- Automatically align by label; the first one is the base dataset; data with the same label are added together, and those with different labels create a new column; this process repeats.
- User-added fields in the base dataset are still considered new fields after appending. If the appended fields have the same label, that column is ignored.
- Hidden columns can participate in append.
Click Preview Data
at the bottom right of the data model area to preview the data after the associative model takes effect immediately:
There are two ways to delete a relationship:
Delete
from the pop-up menu to delete a single relationship. When deleting a single relationship, other relationships associated with the deleted associated table will also be deleted. That is, there will not be any relationships in the data model independent of the model table; any data set will be related to the model table through one or more links.Delete
in the pop-up menu to delete all relationships associated with that data set.Open the model table data set, create a new metric, and you can use fields from the associated table in the metric expression.
In a model, metrics can only be created for the model table, not for the associated tables.
The metric below uses fields from two data sets:
In a data model, the same data set can be dragged in multiple times. Upon subsequent drags, the data name is automatically appended with (1), (2), etc. For example, in the image below, when the Store Information Table
is dragged in for the second time, it automatically has (1) added, becoming Store Information Table(1)
.
Data set reuse is mainly suitable for scenarios where dimension tables/dictionary tables self-associate to implement multiple levels, such as in an employee table where the employee manager ID and employee ID are self-associated to find out who an employee's manager is.
For instance, in the image below, levels 1, 2, and 3 are reuses of the Dictionary Table
data set. They are interrelated using parentid and id to query up to the topmost parent level. They are associated with the order table, thus allowing the statistics of sales conditions at different levels.
In the data model, you can click Rename
in the upper right corner of the data set to rename it. After renaming, the data set is essentially a new referenced data set, and when linking filters, it does not affect the charts made using the original data set.
As long as the data set names are the same, they will be linked for filtering.
This rule applies to linked filtering and dashboard filters.