mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Create specific FK on Entity and ManyToMany relation table #4954
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @malinink on GitHub (Dec 29, 2015).
Originally assigned to: @Ocramius on GitHub.
I have met one problem.
There are Entities in my DB Schema
But, I assume that Factor could be present if and only if there is project-type relation corresponding to it.
The easiest way is to create FK from Factors (project_id, factor_id) to project_factor (m to m relation).
But I didn't find any way to do that.
Am I miss something?
@Ocramius commented on GitHub (Dec 29, 2015):
From your wording, this sounds like you want a
ProjectTypeentity thatyou can reference from a
Factor(non-nullable association).In OO terms, this would simply mean:
class Project {}
class Type {}
class ProjectType { public function __construct(Project $project, Type
$type) { /* ... _/ } }
class Factor { public function _construct(ProjectType $projectType) { /
... */ } }
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
On 29 December 2015 at 11:28, malinink notifications@github.com wrote:
@malinink commented on GitHub (Dec 29, 2015):
@Ocramius
Thanks for the answer. Yes it is one of the way it could be done in doctrine. But, Actually there is some addition information about that DB.
We need Factor depend on Project directly (There is one on the common operation to retrieve all factors of Project). In The case that you are providing it is some overhead to do that.
Also new object adds more actions inside business logic in project - types relations.
May be there is any opportunity not to remove an exists FK, or add it manually?
I think that also there could be Entity configuration that supports multiple FK on one property. Isn't it?
Thank you!
P.S. Actually that DB Schema is result of denormalization process.
@Ocramius commented on GitHub (Dec 29, 2015):
On 29 December 2015 at 14:37, malinink notifications@github.com wrote:
Not really: you reference one thing, therefore you should have one FK.
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/