Jump to content

HELPPP PLEASSEEE!!!!!!


stalian4002

Recommended Posts

I am writing a program to store family tree data, similar to the

GEDCOM format.  I need help writing a sql query to get all the relatives and

determine the relation (father's mother, brother's wife, etc)  for a

particular user.  Here is my basic table structure:

 

Table Users

-UserName (PK)

-FirstName

-AsChildInFamilyID

-AsSpouseInFamilyID

-AsParentInFamilyID

 

Table Families

- FamilyID (PK)

- MarriageDate

 

Table FamilyMembers

- FamilyMemberID (PK)

- FamilyID (FK)

- UserName

- Relation (0 - Husband, 1 - Wife, 3-Child)

 

---> So, given any user, I need to find all the relatives (traverse up as

well as down the tree) and also calculate the relationships as I go along.

The relation column stores the relation specific only to the family (that too

not very accurate, because for instance the husband is actually the father to

the child, not the husband), but I need to "update" the Relation field to

include the depth of the traversal.

 

Based on my table structure, a family unit is husband, wife and

children....I somehow have to recursively find all the ascendants,

descendants, etc...

 

Any help on how I can do this would be great. I am using mysql

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.