I’ve a relationship table for my many-to-many entities.
author_id | book_id
Do I need to add relation_id? I should be able to identify using both id.
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since you’re using Doctrine, try not to think too much on the RDBMS level (at least, not most of the time).
If you have two Entities with a ManyToMany relationship, you should forget about the surrogate key. In fact, you should pretty much ignore the fact that the relationship table exists. You simply have two related entity types.
Now, if you need to store metadata about the relationship itself (for instance the date a badge was awarded to a user), you’re going beyond a simple ManyToMany, and you need to model that relationship yourself — by creating a new kind of entity (a UserBadge, for instance). That entity, of course, would have an id.
You’re using an ORM, think about entities, not about tables (most of the time)!