Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vantinhmmo's avatar

Help me query to show a family tree?

I have referencing a family data model: People: (id, name, email) Family: (id, head_1_id, head_2_id) Relation: (id, people_id, related_id, relation_type) people_id is fk with People, related_id is fk with People, relation_type: Son, Father, Mother,...

Parent: (parent_id, people_id, parent_id, parent_type)

parent_id fk with People and pk

Why need table Parent, And how to query to show tree as demo: export const treeData = [ { name: 'Niclas Superlongsurname', class: 'man', textClass: 'emphasis', marriages: [ { spouse: { name: 'Iliana', class: 'woman', extra: { nickname: 'Illi', }, }, children: [ { name: 'James', class: 'man', marriages: [ ] } ], },

Sorry for my poor English, please help me, thank you very much

0 likes
1 reply

Please or to participate in this conversation.