Your Afterpattern Workbase tables can easily become a relational database. Just connect two tables with a "has many" or "belongs to" datatype column.
In order to create a relational database, you must have 2+ tables in a Workbase. Next, simply link one table to another by adding a "has many" or "belongs to" datatype column.
This brief video provides an overview:
Sending relational data means that your App creates two rows across two Workbase tables, and each row is linked to the other via "has many" and "belongs to" columns.
You can only send relational data from the 'send data' function that creates the row that "belongs to" the other.
For example, imagine a 'send data' function that creates a row in a Children table. Each row in the Children table "belongs to" a row in a Clients table. The key issue is determining what variable to send over to the "belongs to" column:
You have two options:
The 'send data' function variable is found here:
As always, the first step when pulling data into your app is adding a data source.
A data source is equal to 1 table. To pull relational data into your app, you will need at least 2 data sources, one for each table that relate to each other:
Now that you have 2 data sources, here is the most common way to pull relational data from them:
Add to your app the ability to "look up" a row from Table 1, the "has many" table.
There are four methods for "looking up" rows in a table (review the four methods). For example, you could add your app to the Workbase toolbar of Table 1 (this eventually allows you to "look up" a row from Table 1 by clicking on that row directly from the Workbase):
Now you can "look up" a row from Table 2 using the Key Column of Table 1.
The most common method of looking up data in this situation is a Query Block (watch demo of Query Blocks):
The Query Block creates a variable (`list of related children`) that is equal to a list of all rows from your Table 2, the "has many" table.
The Query Block creates this list by performing a filter on your table using the expression you create. This expression instructs the app to find the "belongs to" column (in above example, that column is named 'Child of') and filter for those rows where that column equals the Key column from Table 1.
Now you have a variable that is equal to a list of data. Learn how to use lists.
Want to duplicate the example Workbase and apps used in the video above?