Is it possible to add a Foreign Key column in the database to my child entity?

Certified Associate Developer

So what's happening is I have a One-To-Many relationship between a Parent entity and a Child entity. I want to create a flat relationship between the two entities instead of having to nest my Child CDT within my parent CDT, so meaning I want to have an INT field within my Child CDT, which will contain an INT value equivalent to the PRIMARY KEY value of the Parent CDT.

I referred to this documentation here: https://docs.appian.com/suite/help/19.4/cdt_design_guidance.html and had put the @JoinColumn annotation inside of my Child FK field in order to reference my parent CDT. My question is how does Appian know which table to reference as the child entity's parent? I also tried passing in my parent table inside the table parameter inside the @JoinColumn annotation.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    This is actually the way I prefer to handle nested relationships, because at the end of the day, dealing with flat CDTs and tables can be quite a bit less of a headache than dealing with nested ones.

    The trick is, the child CDT doesn't know or care what the parent relationship is when you don't nest the CDTs.  You just keep track of it manually within your process.  Disclaimer, I'm not all that sure what the @JoinColumn annotation does - my suspicion is that it's not really relevant when you're dealing with a strictly flat relationship structure (and dealing with the nesting aspects manually).

Reply
  • 0
    Certified Lead Developer

    This is actually the way I prefer to handle nested relationships, because at the end of the day, dealing with flat CDTs and tables can be quite a bit less of a headache than dealing with nested ones.

    The trick is, the child CDT doesn't know or care what the parent relationship is when you don't nest the CDTs.  You just keep track of it manually within your process.  Disclaimer, I'm not all that sure what the @JoinColumn annotation does - my suspicion is that it's not really relevant when you're dealing with a strictly flat relationship structure (and dealing with the nesting aspects manually).

Children
No Data