Extending the parent-child relationship
-
20-08-2019 - |
Question
Given the one-table design given below how would the following best be queried
- The set of extended family members given a folk id
- The set of common ancestors given two folk ids
- The set of descendants given a folk id
*Bonus 1st cousins, twice removed given a folk id
Table Folk
FolkID (PK)
MotherID (FK to folkid)
FatherID (FK to folkid)
Name
Gender
Solution
Someone has to build a familytree application? I did something similar some time ago, using XML and XPath:
<Persons>
<Person ID="1" Name="Minu eesnimi" Surname="Minu perekonnanimi" Picture="0" Sex="M">
<Event Name="Birth" Prefix="" Location="Tallinn" Date="14.01.1963"><![CDATA["Ilusal jaanuarihommikul"]]>
</Event>
<Event Name="Death" Prefix="" Location="" Date=""/>
<Father ID="2" Type="Päris"/>
<Mother ID="3" Type="Päris"/>
<Spouse ID="4"/>
</Person>
...
String XPath="child::*/child::Person[child::Father[@ID=\""+String(ID) +"\"] and child::Mother[@ID=\""+String(Spouse)+"\"]]"; etc.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow