+ 2
How to create family tree database design?
How can create tables and relationships for family tree? I don’t want create table for each generation. it’s not possible to use parent-child relationship because a child can be parent.
5 ответов
0
What we can say for sure, is that every person has exactly one father and one mother. So this can be solved with a single "person" table which contains all family members, with the reference to each parent in different fields.
Then you can build a hierarchical recursive query to find all ancestors of a child.
0
Family tree may have more than 5 generation, not just a father and mother and they children. And if use one table for many families with many rows its not good way.
0
it is a graph
one table of Persons
second table for relations:
Person1, Person2, relation_type
then you can list all near relations to Person1
0
zemiak can you explain more please
0
hamid
You can take a look here for more clues:
https://stackoverflow.com/questions/3897952/creating-a-list-tree-with-sqlite