Skip to main content
March 2, 2021
Solved

Object-oriented and domain-driven-design using custom data types.

  • March 2, 2021
  • 8 replies
  • 0 views

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

Best answer by ahmada344

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

8 replies

March 4, 2021

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.

roelc0001Author
March 4, 2021

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!

Kind regards,
Roel

stefanhelzle0001
Brainy
March 4, 2021

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