0

There is a existing database and we have multiple columns to decide Table Per Hierarchy.It is not convenient to add any new column as discriminator. We have Table Per Hierarchy database structure as below.

  • Product - Base Entity (Database Table)
  • Glass - Child Entity (Model class)
  • Parts - Child Entity (Model class)
  • Others - Child Entity.(Model class)

(Update) Discrimination as below,

  • Glass - ProductID > 1Lac < 2Lac & ProductType = 1,2,3,4,5,100
  • Parts - ProductID > 2Lac <= 3Lac & ProductType = 100,101,201,203,204
  • Others -ProductID > 3Lac <= 4Lac & ProductType = All other product type.

Table also contains columns (VarBinary, XML type) which shares between Base and Child entities as per type. I want to get Records for Glass structure from Product table. How can I get this without any discriminator column provided?

Jatin Dave
  • 734
  • 1
  • 7
  • 14
  • Clarify what do you mean by "we have multiple columns to decide Table Per Hierarchy". Also "We have Table Per Hierarchy database structure as below" - are these tables or classes? If they are tables, then it is not TPH. TPH means single table. – Ivan Stoev Sep 22 '21 at 05:27
  • @IvanStoev Thanks for your answer, I have updated my question. Only Product table is Db table, other are classes. – Jatin Dave Sep 22 '21 at 05:58
  • You're right, "It is not convenient to add any new column as discriminator". The whole model needs refactoring. It's impossible to keep working with a model that has developed that many severe anomalies over time (assuming that it wasn't original design!). It's error-prone and probably impossible to keep it performing well. – Gert Arnold Sep 22 '21 at 07:20
  • People living outside India aren't going to understand what is a "Lac". – James Z Sep 22 '21 at 14:21

0 Answers0