We are currently performing maintenance on Appian Community. As a result, discussions posts and replies are temporarily unavailable. We appreciate your patience.
Hello,
Given this small domain model excerpt, how could I represent / create this using Appian custom data types? More specifically concerning the class inheritance of Product, Treatment and Implant.
When using an object-oriented language like C# I would typically employ a TPH, TPT or TPC table inheritance strategy in combination with an ORM framework to solve this.
Kind regards,Roel
Discussion posts and replies are publicly visible
So, if I understand this correctly, in my humble opinion, this can be done by referencing the "product" CDT as a field inside each of the "Treatment" and "Implant" tables with no problem.
Hi Ahmad,
Thank you for your reply!
I suppose I need to wrap my mind around the fact that there is no such thing as "CDT inheritance" like in object-oriented programming languages. So I did as you prescribed above and that indeed could possibly work. I would want however that the productId foreign key in the treatment table also at the same time becomes the primary key.
Can I achieve this by nesting the product CDT in the treatment CDT or should I only specify a productId field as primary key and specifiy the joins in a query? How can I be sure that the foreign key will be properly indexed in the underlying database to ensure performant joins/queries?
Product CDT
Treatment CDT
Treatment Table in SQL Server
Thanks in advance for your help!
Data design in Appian is pretty simple most of the time. There is some guidance available
https://docs.appian.com/suite/help/20.4/cdt_design_guidance.html
I think that, if you want to make (for whatever reason) the foreign key in a table function as a primary key, you'd need to (as Appian doc describes it) "flatten the DB, where you'd manually add the foreign key references to tables and manually join them together. then you can set a foreign key reference in the "treatment" table as a number(integer) and make it a primary key, while saving the reference to the "product" table.
see this for reference: https://docs.appian.com/suite/help/20.4/cdt_design_guidance.html#flat-cdts
Thank you Stefan and Ahmad for your answers! The way that the primary and foreign keys should be defined is clear to me now.
What about my second question: How can I be sure that the [the primary and] foreign key will be properly indexed in the underlying database to ensure performant joins/queries?
If you define your data structure via nested CDTs then Appian will create all necessary tables and indexes. If you go with a flat structure, then you need to create a separate SQL script which creates the things you need in addition to the tables.
Ok that's clear, thanks!
Glad I could Help : )