Thursday, November 5, 2015

Using #neo4j graph database for my [extended] family tree

I’ve been using #neo4j for more than 1 year and today I will share my story with it when I decided to use it for building my family tree with 11 generations.

The rule
In our culture, a person usually get family name (a.k.a last name) from its father. That mean only men’s children will be counted as a member in the family tree.
However, since I’m greedy I will extend the classic model to everybody that I can find

The model
I have 3 node labels: PERSON, LOCATION and NOTE
I have 5 relationship labels: PARENT, MARRIED, LOCATION, LOCATED_IN, NOTED
These are types of relationship:
(parent:PERSON)-[:PARENT]->(child:PERSON)
(person:PERSON)-[:LOCATION]->(location:LOCATION)
(person:PERSON)-[:NOTED]->(note:NOTE)
(sub:LOCATION)-[:LOCATED_IN]->(sup:LOCATION)

The data
  • (:PERSON): 818 nodes
  • (:LOCATION): 43 nodes
  • (:NOTE): 30 nodes
  • [:PARENT]: 810 relationships
  • [:MARRIED]: 284 relationships
  • [:LOCATION]: 821 relationships
  • [:LOCATED_IN]: 41 relationships
  • [:NOTED]: 44 relationships
My discovery
Find all my ancestors:

Total [extended] family members start from my grandfather:

Total [real] family members start from my grandfather:

Find relationship between my 2 niblings:

Conclusion
There are lots of use cases for graph database and there are lots of graph databases out there but #neo4j really impressed me about its power and simplicity. Using #neo4j in my family tree does help me discover a lot of interesting information.

No comments:

Post a Comment