Neo4j and Family Trees
While the relationships in this family tree are currently modeled with binary gender roles (son_of, daughter_of), I fully acknowledge and support our non-binary and gender-diverse folks. This initial design is a simplification for the sake of clarity, but anyone can expand the model to better reflect inclusive and diverse family structures.
Why Build a Family Tree?
Recently, I had the rare opportunity to spend extended time with my parents—something I hadn't done in over two decades. Our conversations often revolved around relatives: those we missed, those we remembered fondly, and those we were simply curious about.
What started as a simple mind map with a handful of names and relationships quickly evolved into something far more ambitious—a fully-fledged graph database built with Neo4j.
From Mind Map to Graph Model
Defining Relationships (Semantics)
Before building the family tree, I needed to define the relationships that would make up the graph's structure. In graph databases, this is referred to as the meta-model or semantics—essentially the "rules" for how nodes and relationships are connected.
Here are the core relationships I established for the graph:
married
: Represents a marriage between two individuals.daughter_of
: Indicates a person is the daughter of another individual.son_of
: Indicates a person is the son of another individual.
With just these three relationship types, I was able to capture a significant portion of the family tree. While I encountered occasional needs for brother_of
or sister_of
, I have deliberately avoided adding more relationships like father_of
or mother_of
for now. Keeping the model simple and focused helps maintain clarity as the tree grows.
Choosing Neo4j for the Job
Neo4j was my natural choice for this project. Having some experience with Cypher, Neo4j's query language, I decided to install Neo4j Desktop and connect it to a free Neo4j AuraDB instance.
A graph database like Neo4j is perfectly suited for a family tree because relationships are first-class citizens in graphs. Unlike relational databases that would require complex joins, Neo4j lets you directly query relationships between people in an intuitive way.
Populating the Family Tree
Once the setup was ready, it was time to populate the database. Each person in the family became a node, and each relationship (e.g., married
, son_of
) became an edge between two nodes.
The data grew quickly! Here's a small glimpse of how it turned out (I've anonymized the names for privacy reasons):
Where This Could Go Next
As I built this family tree, I started to imagine the possibilities of turning it into a collaborative open-source project. A tool where you could build, share, and grow family graphs with friends and family, all while retaining control over your data.
Interestingly, there are already a few solid solutions out there:
- For a SaaS experience with powerful features, tools like Ancestry.com, MyHeritage, and FamilySearch are excellent choices.
- If you prefer self-hosted solutions, Gramps and Webtrees have a focus on privacy and flexibility, and offer full control over your family data.
That said, none of these tools provide the one thing I envisioned—fine-grained access control over individual nodes (persons) and relationships (edges). I wanted the ability to decide who can view, edit, or contribute specific parts of the tree, whether it’s a single connection or a branch of the family.
So here we are: the idea is brewing, and maybe—just maybe—it’ll turn into something real. An open-source project that combines the power of graph databases with collaboration and security. 🤞 Let’s see where this journey takes me!
Let’s Connect
If this post sparked any ideas, gave you food for thought, or you just want to chat more about Neo4j, Family Trees or Graph DBs, I’d love to hear from you. Drop me a message on LinkedIn.
Thanks for reading!