Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4549302
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:20:28+00:00 2026-05-21T16:20:28+00:00

I need to build a family tree in php and MySQL. I’m pretty surprised

  • 0

I need to build a family tree in php and MySQL. I’m pretty surprised at the lack of open source customizable html family tree-building software there is out there, but I digress. I have spent a lot of time reading about storing MySQL digraphs and family trees. Everything makes sense to me: have a table with nodes (people) and a table with edges (relationships).

The only problem I have is I’m not sure of the best way to store relationships that are not necessarily adjacent, for example sibling and grandparent relationships. At first I didn’t think this would be a big deal because I can just invisibly enforce a parent (everyone has parents) that would resolve these connections.

However, I also need to be able to store relationships that may not have a common parent such as romantic partners. Everything I have read suggests a parent-child relationship, but since romantic partners do not share a common parent (hopefully), I’m not sure how to store it in the edges table. Should I use a different table, or what? If it’s in the same table, how do I represent this? As long as I am doing this with non-familiar relationships, I might as well do it with family too.

To sum up, three questions:

  • How do I represent lateral relationships?
  • If a lateral relationship has a common parent, how do I store it? Should this be a family flag on the table where other lateral relationships are stored?
  • How do I store parent-child relationships where the child is two or more edges away (a grandparent), but the immediate parent is unavailable?

Any help is appreciated, and if anyone has any suggestion for some javascript/html family tree building software, that would be wonderful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:20:29+00:00Added an answer on May 21, 2026 at 4:20 pm

    An idea that comes from the Geneapro schema and RootsMagic.

    person
    ------
    person_id
    name (etc)
    
    life_event_types
    ----------------
    life_event_type_id
    life_event_type_description (divorce, marriage, birth, death)
    
    life_events
    -----------
    life_event_id
    life_event_type_id
    life_event_description
    life_event_date
    
    life_event_roles
    ----------------
    life_event_role_id
    life_event_role (mother, father, child)
    
    person_event_role
    -----------------
    person_id - who
    life_event_id - what happened
    life_event_role_id - what this person did
    

    So you could have a life event of type “birth”, and the role_id tells you who were the parents, and who was the child. This can be extended to marriages, deaths, divorces, foster parents, surrogate parents (where you might have 3 or 4 parents with a very complicated relationship), etc.

    As for storing more distant relationships, you can calculate these. For example, you can calculate the Father of anybody by getting the person who has the ‘father’ role with a matching event_id. You can then get the father of that person, and you have the grandfather of the original person. Anywhere that somebody is unknown, create the person with unknown data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still pretty new to php and mysql, I've build a basic CMS for
I need to build an app (PHP/MySQL but I don't think it matters), letting
We need to develop a family tree portal which also supports functinality like Portal
I need to build tree like representation for my application. For that I am
I need to build some JSON out from PHP. The structure of the JSON
I need to build HTML page to show and organize my results. Where do
This I'm trying for transfer my current Apache/Modperl site to Starman, and need build
I need to build app with user messages (dialogs). I've solved this problem by
I need to build a feature like most of the banks use. Where.. if
I need to build a push system in django, basicly its function is to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.