Building my Family Tree

Designing a Data Structure & the Tools available to create a tree

Bharath Raja
7 min readMay 23, 2016
Basic family tree

This could be the first image that comes to mind when you think of a family tree. I’m no different, I feel the same way too. A father, a mother and connected to them are their kids.

Backstory

Sometime back when I was home talking to my grandma, she asked me to go to a relative’s marriage, because “I’m growing up to be a man” and it’s becoming a responsibility of me. I had no freaking clue who the person was, who they’re marrying or how they’re even related to me. So, I asked her. Now what she said went something like this, “Remember my(grandma’s) brother’s brother-in-law? The one who stays in Chennai. His wife’s cousin is the one getting married”. Okay, if you're focused, you could get the link out of that. But it only raised more questions in me, how many siblings does my grandma have? How many does my great-grandfather have? and who are their sons and great-grandsons? Would they be around my age? In India, families are very much connected to each other. That’s kinda how the system works, a chain of network. And so to start with, I asked my brother’s help in trying to draw out a family chart. Just for our personal reference. He took a pencil and paper and started off with my great-grandfather and he was progressing. But then it occurred to me that everyone, at least beyond my generation would need this, because when I’m older I’m unlikely to remember all my relatives. So I had to keep track of these people for future reference because of the bloodline. And I wanted to create a database of people, just my family, their current contact info, birthdays and such, and make it available to everyone in the huge tree. This would enable anybody to track/contact anybody easily.

The Idea

Before jumping into developing something, I thought of what exactly I wanted.

  • Basic family structure. Ability to create and modify people & relations
  • Admin access, who can edit or create (invite only)
  • Facebook integration, so it’s easier for everyone
  • Information privacy — Public / Family’s family/ Family / Private
  • Relationship and Person search (eg., show all cousins)
  • Handling a deceased person
  • Optional timeline

Data Structure Design

But before diving deep into this extensive list of features, I wanted to design the database of how I was going to store the family data. People suggested me to use some graph DB (neo4j) and get it done with. But I wanted an efficient personal solution. The diagram you saw above was not tangible, because the children are connected to, umm, to a relation. Then I thought of storing all the relations in every single person, this was a foolish idea because you can form derivatives out of relations and thus the number of connections would be redundantly very huge.

Then this occurred to me that, with just two connections, child — father and husband — wife, I could do all the traversals I want. For eg., My mom-side cousin would be my → dad’s → wife’s → dad’s (grandpa) → son’s (uncle)→ son (cousin). Not to be offended I connected children to dad and not mom, I love my mom more by all means. Wait, but then what happens if the parents get divorced? It didn’t occur to me because I haven’t seen it around me, well, EVER. Yes, I haven’t seen a divorced couple in my life. Dot. Welcome to India.
(update Jul 2019: 3 of my close friends are divorced, one remarried)

But If I were to design for divorce, that would break. Also for same-sex couple, who’d be the father? Those were all tough questions and I felt that the children didn’t belong to the father, but to the couple, to the “mating”, to be precise, because tomorrow the “couple” may not exist, but that past event can’t be erased. And that’s where the children should be connected to.

Then I created an entity called “Family”. This family holds information about children. The family also contained the father and mother, but they were connected to each other as “Spouse”. This was a good direction, I felt the family entity would enhance the structure, but still, it was not complete. A person being connected to another person as a spouse, and a family as a child didn’t fit it. So I took the family out of the parents and put it in the center.

An optimal structure for any family

This family would hold information about the relationship and status of the couple and the connection to their biological kids. Then a person is always connected to at least one family as a child, n-families as a parent. eg., His 1st wife, his 2nd wife, his affair and so on (well, hopefully not 🤞🏻). With this, all the traversals were possible and the structure was simplified because every person is only connected to families — as child or parent — and every family only holds two parents(of any gender) and a list of children. Divorce situation was handled and LGBT couples are also accommodated.

That was perfect. Then I started to think of how I’d store this information. Would I need a database? If then, how would my structure look like? I spend some time talking with a bunch of friends to understand the system behind a graph DB. And I realized if I can maintain an adjacency matrix, I can build any graph structure as I want. Assuming that I was going with a file system — not even a MySql. I went ahead and started drawing how my data would look like because my needs were specific and the adjacency matrix was an unnecessary complexity for me.

My Initials thoughts were to have a matrix with Persons on one side and Families on the other. The connection would either say “P” for parent, “C” for child or “ ” for no relation. This was a great start, but as I saw the representation, I realised there were a lot of empty space. Actually most of the space was empty. So I redesigned my data to something like this.

As you can see here, there was a list of persons, with two information on them. Their “child of” family and their “parent of” family list. Of course, there would be two other tables holding information about the person Px and the family Fx. This was just the relationship. I’ve highlighted a family as green. It occurs in four places, the father, mother, and sister. And this implements the structure we saw above. Also, if you look at the uncle you could see that he’s a part of multiple families.

Epic ending

After spending so much time on this, I took a break to see if there were any other implementation already available for me to use. Though I’ve already done this job, I wanted a thorough check again. Sadly, I found GENI which does this extensively, and it had 100 Million families already. With a heavy heart, I signed up and I realized it had (almost) everything I wanted.

Though the interface was horrible, it had all the needed functionality to build any kind of family tree. I was able to invite my brother and my cousins to help me build this and the collaboration was good too. So I eventually built a tree here. But it didn’t feel complete, I don’t think it ever does. Because there are always open ends that you could dig in and keep adding more. After a month, I realized we weren’t using the tool much. As a one-shot, we collected the data, but we weren’t frequent and we stopped at a point. Then I got that, it’s biggest drawback is that they don’t have a mobile solution.

http://www.ancestry.com/

So I found another tool, Ancestry which was primarily based on mobile. This was very cool, easy to use and had all the needed functionality to build a tree. The coolest thing was being able to see it via the mobile. There were some limitations in the app, for instance, you can’t create a brother or sister without adding a parent and I don’t really know my great-grandparents name. The invite functionality wasn’t facebook integrated. Also, I didn’t want to invite others and ask them to do the same work again, for the platform mistake I made. So I decided to fill in all the available data myself before pulling in other people.

Finally, I’m glad that I have a place where I can store all my family relations information and access them when required. One less headache, remembering all the relations you’ve never met. Too bad I didn’t get a chance to build the system. That would’ve been epic.

--

--

Bharath Raja

DevRel 🥑 Engineer 📟 Adventurous 🏂 High-functioning Absurdist. I cherish meaning, truth, beauty and the paradox of their co-existance. bharathraja.in