Advanced Modelling Use Cases
Every database is different, and sometimes one or more of the following edge case scenarios may need to be considered when modelling the data.
Multiple Datasets Mapped to the Same Table
This is typically needed when one table represents multiple logical entities, and each entity should be represented by a separate dataset in the LDM.
While the LDM Modeler supports mapping of multiple datasets to the same table, publishing an LDM with such mapping fails.
To avoid this issue, create multiple views on top of the table and map each dataset to a separate view.
For example, you have two tables, users
and tickets
.
- The
users
table contains ticket creators and assignees. - The
tickets
table contains theassignee_id
andcreator_id
columns.
To avoid mapping multiple datasets to the users
table, do the following:
- In the database, create two views on top of the
users
table:v_users_assignees
andv_users_creators
. - In the LDM, create three datasets:
assignees
,creators
, andtickets
. - Map the
tickets
dataset to thetickets
table. - Map the
assignees
dataset to thev_users_assignees
view. - Map the
creators
dataset to thev_users_creators
view. - Create a relationship from the
assignees
dataset to the thetickets
dataset using theassignee_id
column as a primary key in theassignees
dataset. - Create a relationship from the
creators
dataset to thetickets
dataset using thecreator_id
column as a primary key in thecreators
dataset.
Using Multiple Data Sources in an LDM
Beta Feature
Support for multiple data sources in an LDM is a beta feature and not recommended for production use. Creating links between arbitrary datasets from different data sources is not yet supported, even though the UI can visualize the connection. Also, using multiple data sources in an LDM is not compatible with the Unique Data Sources for Tenants feature.
- You can use datasets from different data sources in an LDM, but they can only be connected using common date dimension datasets. This allows applying a common date filter to them.
- Each visualization or metric can use only a single data source, but you can place visualizations from multiple data sources on a dashboard.
- Attempting to execute a visualization requiring data from multiple sources will not succeed.
- The list of data sources prioritizes those already used in the current model. You can change the data source in dataset mapping.
No Single-column Primary Key in Tables
While the LDM Modeler supports setting multi-column primary keys in datasets, publishing an LDM with multi-column primary keys fails.
To avoid this issue, create one-attribute primary keys in your database:
- Concatenate the table columns that comprise the primary key in the table.
- Calculate a hash value for the concatenated columns.
- Use the hash value as a one-attribute primary key.