can we create a foreign key while creating cdt from scratch?
Discussion posts and replies are publicly visible
https://docs.appian.com/suite/help/22.1/cdt_design_guidance.html
If you nest CDTs, Appian will take care of that.
In case you don't want to nest CDTs, then you can create a CDT via XSD and then use the JPA annotations to establish the foreign key relation on the CDT level but that wouldn't add an FK constraint on the DB level.
I always create my FKs in a script (manually). It also serves as a reminder / nudge to create indexes while at it!