Create a Form with a Dependent Table
Last updated 1/02/2022
Dependent Tables in Five
Initially opening a new Form Wizard, the Dependent Table field will be captioned with Select a Main Table. This is because a main table needs to be selected before the Dependent Table field will become available. Only if the main table has dependent tables established in the database will there be options to select in the Dependent Table's lookup list.
Five supports the object-relational mechanism known as inheritance. Inheritance allows a table to inherit some of its column attributes from another table creating a parent-child relationship. This causes the child table to have each of the same columns and constraints as its inherited table as well as its own defined columns.
When selecting a dependent table in Five you will have access to the fields from both tables to select for your form.
Example
The following diagram shows the child entities inherit all the elements of their parent entity, plus have some additional ones unique to themselves. The parent entity takes on a 'Type' column to hold the type of entity. In the diagram below, we can see the Entity table has three dependent tables. The EntityType column in the Entity table is to store the type of entity.
The Customer table is one of the tables that has a dependent relationship with the Entity table. Inheritance is the mechanism that connects the Customer table to the Entity table, allowing the Customer table to automatically acquire the Entity (parent) table's properties and columns.
Add a Form wth a Dependent Table
Requirement
The main table must have a 'Type' field. The type indicator is a mechanism for determining the type of entity. For example, the Entity table may include an indication of whether the entity represented by the table row is a customer, motor dealer or contact.
Prerequisite
The dependent relationship must be established at the table-level.
Post-Requisites
You will need to edit the Customer form after saving the Form Wizard to perform the following modifications to the Type field.
- The Default Value field will need a value entered that will automatically be stored in the main table (parent - Entity) in the database. For example, C for Customer.
- The Show If field will need to be set to
false
so the field will not be shown on the form.
Steps
- Click the New Form Wizard button in the list app bar.
Click the lookup icon in the Main Table field and select the main (parent) table. For this example, the Entity table.
Click the lookup icon in the Dependent Table field and select the dependent (child) table. For this example, the Customer table.
Click the Next button.
Select the checkbox for each field that is to be mandatory.
Select the checkbox for each field that is to be included in the list.
Click the Save button in the wizard app bar.
info
All the fields from both tables are listed.