Need help about inheritance mapping polymorphic relationships #10333
Unanswered
bocanhcam
asked this question in
Support Questions
Replies: 1 comment 1 reply
-
I see what you’re trying to do, but relational databases don’t work that way. You cannot have the creator_id reference either a member or a customer with a foreign key, depending on the creator_type value. (Yes, you can do this without foreign keys, but again, that’s not how relational DBs are designed to work, and it won’t work with the ORM that way.) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have 3 tables like the above.
I want to make the relationship between column Article with Customer and Member using
creator_id
andcreator_type
.I'm struggling with how to create relationships for these table entities.
I already use
@ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
to define the type of each entity so I don't think of another way how to do it.Can anyone give me a sample code?
Thanks a lot!!!
By the way, I use Symfony 5
Beta Was this translation helpful? Give feedback.
All reactions