In this article
If you wish to set up a balanced hierarchy, you must first have a schema in which the hierarchy is to be created, then you must create a separate table for each level in the hierarchy (go to Inserting a New Table for more information). For example, if “Continents” is the top-level, “Countries” could be the level below.
Add a New Table to a Schema
- Go to the Tables tab.
- Click Add Table.
- Type the name of the table into the Table Name field - .
- Click Save to save the changes.
Figure 1 - Adding a table
Properties
- Click the table ID to edit the properties of the new table - .
- Select the required languages.
Figure 2 - The table properties
Captions
In the event more than one language is selected, go to the Captions tab and enter caption texts for the "non-default" languages - .
Figure 3 - The Captions tab
Relations
In the Relations tab you specify the relationship between the tables. In this example, countries belong to continents; that is, “Continents” is the “parent” and “Countries” the “child”.
- For the Countries table, go to the Relations tab.
- Click Add Relation to set up a relationship, and give the relation a name (in this case “r1” is used).
- Click in the Parent Table field to open a drop-down list of the available "parents", and define “Continents” as the parent table - :
- Save the relationship, then generate the table by selecting it in the table list and clicking Generate.
Figure 4 - Setting up Relations
The “Required” setting defines whether or not a “parent” must be defined for each “child”. In this example every country should belong to a continent, so the "Required" property will be set.
Important:
The relationship name will be used as a column name in the table, so use only alphanumeric characters and underscore in the relationship name.
Contents
In the Tables list, the Generated flag for the Countries table switches to True. Now, when you go to the “Contents” tab for the “Countries” table, you will see that the table will display the relationship as an additional column, after the id and the languages - .
Figure 5 - Table contents
Add ids and texts as previously described. The relationship is specified by the code of the continent (for example NA for North America from the previous example). You can also click the ellipses button (...) next to the relationship field to select from the list in the “Continents” table - .
Figure 6 - The Search window
In the event the selection list is extensive, you can search in the text fields in the different languages using * as wildcard. If you leave the search fields empty, the entire list will be presented. Select one of the items and click Select and Close. When finished with the entire list, click Save and then synchronize the table.
You could then add for example regions or cities as the next levels in the hierarchy in another table. However for simplicity this example will be a hierarchy with only two levels.
Hierarchy
The next step is to define the hierarchy. This is done in the Hierarchy tab in the table list.
- In the Tables list, go to the Hierarchies tab.
- To add a new hierarchy, click Add Hierarchy - .
- Click into the Hierarchy Name field and type in a name for the hierarchy, then click Save.
Figure 7 - Adding a hierarchy
To set up the properties of the hierarchy, click the blue hierarchy id link (it turns orange on mouse-over) - .
Figure 8 - Adding a hierarchy to the database
In the Hierarchy structure tab you select the hierarchy from the available relationships set up in the database. To do this:
Select a “child” or “sub”-node at any level within the tree except the top level. In this case, select the relationship from “Countries” to “Continents” by expanding the tree by clicking the + next to “Continents”, then clicking “Countries” and Save - . This would seem like an unnecessary step for a simple table structure like the one we have set up, but a database schema like this could contain a lot of different tables with different relationships in different levels, so you could have a lot of different structures to choose from in your schema.
Figure 9 - The Hierarchy structure
Survey Messages in Hierarchies
Balanced hierarchies will have text appearing above each drop-down. This text comes from the caption text associated with the table. Unbalanced hierarchies do not have this caption.
Two survey messages are available to control the default text when the question is rendered (go to Survey Messages for more information). These can therefore be customized on a language basis, not on a question-by-question basis. The rules for the text that appears are:
- If a question is required but "Force lowest level" is disabled, then the first drop-down will have the text “– Select –”. All other levels will have “– Optional –”.
- If a question is optional and "Force lowest level" is disabled, then all drop-downs will have the text “– Optional –”.
- If a question is required and "Force lowest level" is enabled, then all drop-downs will have the text “– Select –”.
- If a question is optional and "Force lowest level" is enabled, then the first drop-down will have the text “– Optional –”. All others will have “– Select –”.