I encountered this problem a couple of times in my career and was never very pleased with the solution, and presented it again in the project that I am doing in ASP.Net MVC, C #, SQL Server 2008
Imagine that I have a type Person (class). I also have Mother and Father types that expand the Personality. Father and mother are very similar: they both have a property called "Children", which is a collection of type Person. A "person" can be represented either by the base class Person, or the class "Mother", or "Father". In this example, you can see that I have both inheritance (is-a) and communication (has-a).
I want to create and store family trees on SQL Server using these OO types. I think I want to have these 3 tables: Person, Mother and Father. Each object will have an entry in the Person and, possibly, in the case of the mother and father, if necessary (with the ratio of FK to Person). In addition, I will need some crossword puzzles to store the relationship between the parent record and any child records, as well as with the father.
Does this sound like a good storage strategy?
How would you effectively request this for deep and wide family trees?
The problem I encountered is the polymorphic nature of the returned data and the given node in the tree. If it were just a tree of Person objects, I would use a Recursive generic table expression . But 3 different forms of data can be returned for any giving node that I would like to map to one of the three OO types in C #. I obviously can do recursion in C # or a stored procedure, but I'm not very happy with the performance of such solutions in the past. Also, how can I insert records naturally? I always had to insert the correct order (Person, then Father or Mother) in the past due to the forced FK interaction in SQL Server.
Is there an environment that will handle this type of ORM for me?
Edit:
, , . , . , , ?