I'm having some bad feelings about a task, where sub-sub-sub-childs should get physical parent ids (foreign keys) to a "super parent".
So, here is the current database/orm structure
masterparent->child1->child2->child3->child4->child5->child6
always oneToMany
So it's a quite long chain. Let's take a better readable example in reversed order:
nail->getFingerPart()->getFinger()->getHand()->getHuman() (and assume every fingerPart can have multiple nails ;))
My task now wants to add a column human_id to "nails", "finger_parts" and "fingers" (and not just "hand" having it).
The main reasons for this are the many joins to get all nails from a human and so on. And the entity "shortcuts" like human->getNails() look quite ugly as well: foreach this->getHands() as hand ... foreach hand->getFingers() ...)
Although I don't think it would be a big performance issue (it's not a high performance app where every ms matters), but yea, these joins are annoying and 5-6 nested loops don't let you fall in love into the code.
But I don't know, it just feels wrong.
1.) I guess you'll run into problems with cascade deleting in doctrine.
2.) It looks like you'll mess up the structure as there will be no "source of truth" anymore (finger says it belongs to human 1, hand says it belongs to human 2) - but well, in our special case this wont happen as you won't be able to change the "human". But if this gets a common behavior to avoid joins it certainly will.
3.) In our case you can create new hands, fingers, ... where we need to set the human after this change, so we need to alter quite a lot of code (but I guess, this won't impress the stakeholder).
Any other "conflicts" here which may might happen?
Isn't there a better way like creating a view for this? And then HumanView->findAllBy(["human": 1]); to get all the nails (but with "real" writable entities - not the readonly view ones)?