Data Models Basics
Introduction
A data model is an abstract representation on top of a database table/SQL query that you may manipulate without directly affecting the underlying data.
You can also store additional metadata that enrich the underlying data in the data table. Data model contains information about the data itself, such as: model descriptions, field descriptions, and relationships to other models. You can also extend the data model with calculated dimensions and measures.
Components of a Data Model
A data model consists of:
- Source of Model: Whether it's backed by a Database Table, a SQL query or data from another source.
- Fields: Including Base Dimensions, Custom Dimensions and Measures
- Relationships: Defining how the model connects to other models by specifying the join key and relationship type
- Persistence: Improve model loading performance by turning your logical data model into a physical table in your database.
Types of Data Model
There are two types of data models in Holistics:
- Table models: Models created from existing tables in the database.
- Query models: Models created by writing SQL to select from tables or other query models
Create a model
To create a new model, go to the AML Studio, click on the +
symbol next to a folder, and select the type of model you want to create.
After that, a new screen will pop up to help you finish with your model creation. Depending on the type of the model, the screen will be different:
- Table Model
- Query Model
For more details, please refer to the dedicated documents of each model type.
Model Metadata
After creating a model, it is good practice to add more metadata to help you (in the future) and other developers to understand the model better.
In this section, we will go through the metadata that you can add to a model.
Model name
Model name is the unique identifier of your model within a project.
- For Table Models, the model name is automatically generated.
- For Query Model, you specify the model in the "Input Model Name" box when writing the query.
Model names can be changed later, but look out for potential breakage if you have used the names in downstream models, datasets and reports.
Please check our document about File name vs. object name for more details on this topic.
Model label
Model label is the display name for the model that can be more descriptive, or simply looks nicer comparing to a more verbose model name.
For example, you can set the label of model ecommerce_users to Users :
As a result, this model will be displayed as Users in a dataset:
Model description
Model description is another way to provide more context for the underlying data. Model description can be written in Markdown:
Sync schema changes from database table
When you make changes to the schema of the underlying database tables (like adding new columns, delete columns, change column's data type...), you can sync those changes to the model's metadata.
To initiate the sync, navigate to Modeling 4.0 > Your Data Model >
Refresh model.The effect of this sync is as follows:
- When you add a new table column, a new corresponding model field will be added in the model
- When you delete a table column, the corresponding model field will be still remain, but Holistics will through an error if you include the field in an exploration.
- When you rename a table column, a new model field with the new column name will be added. The field with the old column name will remain, so you need to manually remove it.
- Changing data type of table columns in the database will change the data type of the model fields.
- When you delete the underlying table, the model itself is unaffected. You can change the source table of the model, but make sure the new table's schema is compatible with the model.