When I should use nested fields and when I should avoid it?

What are the cases to use nested fields? 

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer
    Hi oksanak,

    For better understanding follow the below link
    docs.appian.com/.../CDT_Relationships.html
  • Best Practice is to void nested CDT's because when get the data you will unnecessarily get all child table data(where query entity have a limitation on get to be fetched) and it make the scenarios bit complex.

    Instead use separate CDT's and make one columns same with CDT's to maintain the relation ship, by this way use can concentrate on each module individually.
  • Hi ,

    Nested fields you mean to say nested CDT's right ?

    In that case below are the use cases where opting for nested CDT's might help.

    1.When you have a parent and child relationship CDT's be it one to one or one to many.

    docs.appian.com/.../CDT_Relationships.html

    Lets take a simple example of employee and its department.

    So inorder to fetch the employee data along with his position and department, you can create a view joining both the employee and department table or else you can go for the nested CDT's

    There is no need for creation of view if we use nested cdt.

    2.We can fetch data of child cdt from parent cdt

    Let’s say that our employee CDT was nested, with department and title living in a nested position CDT. When we go to query the data our expression would look something like this:

    a!querySelection(columns: {
    a!queryColumn(field: "firstName"),
    a!queryColumn(field: "lastName"),
    a!queryColumn(field: "position.department"),
    a!queryColumn(field: "position.title")
    }
    )
    The alias parameter in a!queryColumn() can be used to make referring to nested values easier in an interface expression.

    docs.appian.com/.../Adapt_a_SAIL_Recipe_to_Work_with_My_Applications.html

    But It has much more limitations than advantages:

    1. Debugging of process instance is much difficult.
    2. We can't give a name of column in master table.
    3. Unnecessarily we need to fetch child table data


    and many more disadvantage So View is much better approach than nested cdts.
    Some more issues could lead into complex looping when you are working in Nested CDTs which would potentially lead to High health checks. However it varies from case to case.
  • Hi oksanak,

    As per my understanding flat relationships are mostly preferred because it takes advantage of specific query performance optimization which is made directly in to the database.If we use nested Cdts it is a bit complex due to several issues like resolving a process,accessing additional data,and more over deleting the child value also becomes difficult.In order to avoid these it is better to go with flat relationships.

    Thanks,
    ravalik