Hi
I'm trying to develop a simple application with Redbeanphp but I'm struggling with multiple one to many relationships to the same entity:
Say I have an entity called "person" and an entity called "animal", I would like to store liked animals and disliked animals for a certain person.
When I try something like this
$person = R::dispense("person");
$cat = R::dispense("animal");
$cat->name = "cat";
$dog = R::dispense("animal");
$dog->name = "doggo";
$person->ownLikedAnimalList[] = $cat;
$person->ownDislikedAnimalList[] = $dog;
I get the following tables
PERSON(id)
ANIMAL(id, name, person_id)
from now on there is no way to tell if an animal is disliked or liked by a certain person because every animal refers to the person table in the same way.
I found questions like this one where a lot of people suggested to use many-to-one relationships but i don't think it is the right way
of doing it: I think it would be correct to have some kind of intermediate table to handle the relationship between a person and its
liked animals and another intermediate relationship for disliked animals.