:) hello frnds
i wana ask one question about my project.
i m dng the project of family tree.
in wch many relationships r one person make his own family tree thn another parson in his family can make the relation ship wth him.and tht will specify the relatinship among them.tht i wana specify eth relation name.
plzz,anyone can help me in this task.wht coding actually take place here.
how can i make this relationship.

Dani AI

Generated

Short practical plan for (and thanks to for prompting code/sample): model the family as a graph (people = nodes, relationships = edges), store parent edges directionally and spouse edges bidirectionally, and compute kinship by walking that graph. Avoid duplicate forum posts as noted.

Database model (recommended)

  • Person table: PersonID, Name, Gender, DOB, etc.
  • Relationship table: FromPersonID, ToPersonID, RelationType (Parent, Spouse, Adoptive), optional IsDirected.
    Store parent links only in one direction (parent -> child). Do not store siblings explicitly — derive siblings from a shared parent to keep the model consistent.

Algorithm to name a relationship

  1. For each person, walk parent links upward (BFS) to collect ancestor nodes with distances.
  2. Intersect ancestor sets to find nearest common ancestor (minimize sum of distances).
  3. Let rA and rB be parent-steps from A and B to that ancestor.
    • If rA = 0 or rB = 0 => ancestor/descendant (parent, grandparent, great-grandparent).
    • If rA = 1 and rB = 1 => siblings.
    • Otherwise use the standard cousin formula: cousin degree = min(rA, rB) - 1; removed = abs(rA - rB). See cousin rules for details and edge cases.
  4. If any spouse edges were used in the discovered path, append "by marriage" / treat as in-law.

References: basic graph search for shortest paths and ancestor traversal (Breadth-first search) and cousin-degree rules (Cousin).

Example VB.NET sketch (ancestor BFS + LCA distance)

Public Function GetAncestorDistances(startId As Integer) As Dictionary(Of Integer,Integer)
    Dim q As New Queue(Of Integer)
    Dim dist As New Dictionary(Of Integer,Integer)
    q.Enqueue(startId) : dist(startId) = 0
    While q.Count > 0
        Dim cur = q.Dequeue()
        For Each pId In People(cur).Parents
            If Not dist.ContainsKey(pId) Then
                dist(pId) = dist(cur) + 1
                q.Enqueue(pId)
            End If
        Next
    End While
    Return dist
End Function

Notes and cautions: keep gender flags for "aunt/uncle" wording, handle multiple marriages and adoptions explicitly, and validate data to avoid cycles. For very large trees consider a closure table or cached ancestor indexes to speed queries.

Recommended Answers

All 3 Replies

First, if you wish to receive help, use proper grammar and SPELLING.
Second, show us what code you have to this point, and we will try to help you through the parts you are stuck on.

sorry for my misteak.actually my english is not perfect.i want code that make ralationship between two person in family tree.i know here i want to use loop conditions but how that please explain.If again there any misteak then plz try to understand and plz help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.