tags:

views:

134

answers:

1

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
A: 

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&#228;ris"/>
          <Mother ID="3" Type="P&#228;ris"/>
          <Spouse ID="4"/>
        </Person>
...

String XPath="child::*/child::Person[child::Father[@ID=\""+String(ID) +"\"] and child::Mother[@ID=\""+String(Spouse)+"\"]]"; etc.

Riho

related questions