反馈已提交

网络繁忙

Tree Dataset

  • Last update:  2023-08-17
  • Overview

    Version

    FineBI Version

    5.0

    Application Scenarios

    How to import or synchronize their department hierarchical structure when you import or synchronize users?

     1.png

    Functions

    In a database, you can often see a table structure with two fields (ID and Parent ID) or with a field who has certain length pattern. This table structure can form a tree dataset, through which a tree-like hierarchical structure can be generated.

    Example

    Preparing a Data Table

    Click to download the data table: Company Department.xls.

    The information of the table is shown in the following figure.

     2.png

    Add Company Department Table to your own database, or create a user information table in your database.

    Creating a SQL Dataset

    Log in to the decision-making system as the admin, choose System Management > Data Connection > Server Dataset, move your crusor to Create Dataset, click SQL Dataset, set Dataset Name to Company Department, enter SQL statements, and click Save.

    The SQL statement is as follows.

    select *from Company Department

    3.png

     4.png

    Creating a Tree Dataset

    Method One: Creating Tree Depending on Parent Tag Field of Selected Dataset

    1. Click Tree Dataset, set Dataset Name to Department Tree, and set Original Tag Field to Department ID and Parent Tag Field to Parent ID.

     5.png

    6.png

    The tree dataset comes from the SQL dataset created in section "Creating a SQL Dataet". There are Department ID and Parent ID fields in Company Department, so you can choose Create Tree Depending on Parent Tag Field of Selected Dataset.

    In this case, there needs to be a unique root node (a node with an empty Parent ID). If not, the index cannot be established normally when you build the tree.

    2. Click Preview. Then you can see the data as shown in the following figure.

     7.png

    Three new fields can be seen in the dataset: FR_GEN_0 (the first level of the tree structure), FR_GEN_1 (the second level of the tree structure), FR_GEN_2 (the third level of the tree structure).

    3. Click Save.

    Method Two: Creating Tree Depending on Length of Selected Dataset's Tag Field

    1. Click Tree Dataset, set Dataset Name to Department Tree, and set Original Tag Field to Department ID.

     8.png

    9.png

    The level of fields (without parent fields) in the data table is determined by their length. The length of the field Department ID in Company Department is different. But there is a certain pattern. The first number represents the department ID of the first-level department. The second number together with the first number represents the department ID of the second-level department, and so on.

    iconNote:

    Department ID, Parent Department ID, and Department Name are three tree-building fields. In actual operation, the Department ID and Department Name fields must correspond with each other. There cannot be duplicate Department IDs.

    2. Click Preview. Then you can see the data as shown in the following figure.

     10.png

    Three new fields can be seen in the dataset: FR_GEN_0 (the first level of the tree structure), FR_GEN_1 (the second level of the tree structure), FR_GEN_2 (the third level of the tree structure).

    3. Click Save.

    Requirements for Generating Tree Dataset Tables

    Original Tag Field and Parent Tag Field as Number

    Data Table

     11.png

    The above data table is a complete tree dataset. When you build the tree dataset, the Department ID is Original Tag Field, and the Parent ID is Parent Tag Field.

    The first row indicates that the tag of Headquarter is 1, with empty parent tag, meaning that Headquarter is a root department without a parent department. (Usually, if a department does not have a parent department, the parent department tag is empty.) The second row indicates that the original tag of Human Resources Department is 11, with parent department tagged as 1. You can query the parent department based on this tag.

    You can know all department and position information in the dataset. According to Parent ID, you can locate Department ID, search for the corresponding Department Name, and create the field Parent Department.

    Description

    Any tag (except those being empty) in Parent ID must be found in the corresponding tag of Department ID. All values of Parent ID in the above figure have corresponding values in Department ID.

    If Parent ID is 2, with no Department ID as 2, the tree is considered incomplete, because it is impossible to construct the department information with Parent ID as 2. If the dataset that contains user information is synchronized, it will fail.

     12.png

    Original Tag Field and Parent Tag Field as Letter

    Data Table

     14.png

    When you build the tree dataset, the Department ID is Original Tag Field, and the Parent ID is Parent Tag Field.

    The tag of Parent ID need to be found in Department ID, otherwise synchronization will be rejected.

    Description

    The following shows necessary conditions that can help you determine whether a tree dataset is correct.

    1. The values (except those being empty) in parent tag fields have corresponding values in original tag fields.

    2. Rows with the same original tag fields need to have the same department name and parent tag fields (like the last two rows of the data table shown above).

    3. Rows with the same parent tag fields and department name need to have the same original tag fields (like the last two rows of the data table shown above).

    The following shows scenarios in which a tree datasets cannot be created.

    1. If a department has two parent departments, the table is not a tree structure.

     15.png

    2. If a tag has different department names, the synchronization will not be finished.

     16.png

    3. If the department name is unique, its department tag will also be unique (under the condition that there is a definitive parent department). The following figure shows an incorrect scenario.

     17.png

    Department names can be the same. For example, Performance Group can be included both in the sales department and in the R&D department. If the parent department is determined, however, department names cannot be duplicated.

    For example, both Lyon and Loy are in Performance Group, whose parent tags are both d. The tags of same departments should also be same. But in the figure, the department tags of Lyon and Loy are different, which will lead to an error and a synchronization failure. If Parent Department is determined, you can determine a unique department according to Department Name.

    4. Some enterprises who perform flat management may have flexible superior-suordinate relations. For example, department A is the parent department of department B, which is also the parent department of department A at the same time. This scenario (very rare) will also lead to synchronization failure.

    Notes

    Tags like 0 and 0000000 cannot be contained in original fields and parent tag fields, because these tags will be parsed as 0, which is a reserved field in the program and is the ID of all departments. You need to avoid using them as much as possible.

    If a department does not have a parent department, keep Parent Department field empty when you create a tree structure.


    附件列表


    主题: System Management
    Previous
    Next
    • Helpful
    • Not helpful
    • Only read

    feedback

    鼠标选中内容,快速反馈问题

    鼠标选中存在疑惑的内容,即可快速反馈问题,我们将会跟进处理。

    不再提示

    10s后关闭