How to have recursive tree genealogy in symfony

9
February 11, 2019, at 1:10 PM

I'm making tree genealogy in symfony.

I have two entities :

User: id    firstname    partner    
       1    Julien       Anne      
       2    Eric         Marie    
Relation: id    family_id    child
          1     1            Manon 
          2     1            Camille
          3     2            Julie

I would like to have recursive tree genealogy like child can have partner and can have children but I don't know how to do that.

Shoud I need an other entity ?

Thank you for your help

Answer 1

You need to think about your data design before you start trying to apply it to a particular programming environment.

Think about separating (all) People from (all) Relationships.

Person: Name, Id (and any other demographics you want to store, e.g. date of birth)

Relationship: Id1, Id2, Relationship Type

Relationship Type might be Partner, Child.

Then you can give a child a partner, or a child of their own, without trouble.

Hope this makes sense.

READ ALSO
PHP Subscribe Form with Email Duplicate Check

PHP Subscribe Form with Email Duplicate Check

I'm very new to PHP and struggling with adding in duplicate email check with this code

24
Send Message to Telegram Bot Without Open Telegram Apps

Send Message to Telegram Bot Without Open Telegram Apps

usually if we want to chat or send command to Telegram Bot, we just texting the bot from Telegram apps (desktop, web, or smartphone)Is there any way texting the bot without open Telegram apps?? I've read many website and thread in stackoverflow, but no clue

43
htaccess file is not working properly in Laravel on linux

htaccess file is not working properly in Laravel on linux

I'm working on a Laravel projectI'm Removing "/public" from URL but it's only work on welcome page, other page like /login,/register is doesn't work properly

42
Google calendar add event wrong clock

Google calendar add event wrong clock

When I add an event with start date : 2019-02-10 at 08:00 for exampleThe event in the calendar is starting the 2019-02-10 at 09:00 (with 1 hour more)

35