Relating Data
Create a relationship between tasks and time records to know who performed which task and how much time was spent.
By the end of this step, the Record form will be related to the Task table, allowing you to view the associated task directly in the records listing.
Prerequisites
Before you begin, make sure you have already completed:
- The creation of the Task form with the
namefield. - The creation of the Record form with the basic fields for hours worked.
- The configuration of the corresponding tables in the Database.
For more details on how to relate data, see the Interface Guide: Relations.
So far, you have created task management and a time log, but each list still works in isolation.
It is important to relate them, so that each time record clearly indicates which task was performed by a collaborator and in which period.
In this step, you will:
- Create a field of type
selectin the Record form. - Configure the field to relate to the Task table.
- Update some data to see the relationship working in practice.
Field of Type select
Add a field that will allow you to select the task associated with each time record.
- In the Build environment, open the Record form and access field management.
- Create a new field with the following settings:
- Field Title:
Task - Column Name:
task_id - Type:
select
- Field Title:
- Enable the Required option to ensure that every record is associated with a task.
- Keep the Unique Values option disabled, since there will be many records for the same task.
We suggest the name task_id to maintain a consistent naming standard across the entire data model.
Use the _id Suffix
The name of the field that references another record must end with _id.
This pattern makes it easier to identify that the field represents a relationship with another table and keeps the data model better organized.
Avoid using generic names such as task or ref_task for relationship fields.
Standardizing with _id helps avoid confusion when you are analyzing data or creating integrations.
Configure the Relation Link
Configure the Link, which is responsible for relating the task_id field to the tasks table.
- In the newly created field (
task_id), scroll down to the Link configuration section. - Click Add.
- In the window that opens:
- Select the task option.
- Then select the name field.
- Close the window to apply.
When you finish, the Link will be defined as:
task:name
This means that:
- The relationship will be made with the task table.
- In the interface, the value of the name field of the task will be displayed when selecting in the
Taskfield.
Click the Save button to save the field configuration.
Whenever possible, use a descriptive field (such as name) to display the related information, instead of a technical or numeric identifier.
Update Records
With the relation field configured, adjust the data to visualize the result.
- Access the view of the Record form.
- Note that now the results table has a new column called Task, which will initially be empty.
- Edit some records:
- Click on a row in the results table to open the edit form.
- In the Task field, select the corresponding task.
- Click Save to save.
After saving:
- The Task column in the results table will now display the name of the associated task.
- Each Record will be clearly related to a Task, allowing a more complete analysis of the time spent on each activity.
If there are many records without a defined task, consider updating them in batches or defining a temporary default task, according to your data policy.
Expected Result
The Record listing should display:
- A Task column filled with the names of the associated tasks.
- Each row representing a time record with its respective task, making it simpler to identify where the time was invested.
Next Steps
In the next topic, you will see how to create a Service to expose this data and use it in other parts of the application, such as reports or custom interfaces.