if our situation is the standard view where you have two tables and a ternary, and easily manageable by following the following documentation
But if we have three instead of two tables and then the ternary consists of 3 PrimaryKey, as I write my yml files?
Example to situation:
Take the case that I have a user who participates in a course.
So I have a users table, courses table and a users_has_courses (useri_id, course_id).
This is the standard case many-to-many.
But I also have a table invoices and therefore a table users_courses_invoices where there are three primaykey (user_id, course_id, invoice_id).
In your situation you have the
Userand theCoursemodel and they are linked with a many to many relation which has the pair(user_id, course_id)as key. I would call this model subscription, and give to that its own identifier, and then I will link this model with theInvoicemodel, so your final scheme (minimal version) could be:In this way you have a normalized database and you can access invoices both from users and from courses with this code:
If you want all invoices for a given users you can do a query in this way
The same apply if you want all the invoices for a given course.