There are a few issues:
Your table names should be pluralized:
course
should be courses
student
should be students
course_membership
should be course_memberships
Note this section from the CakePHP cookbook:
"CakePHP does not support composite primary keys."
The course_memberships
table should have a primary key of id
that auto increments and the composite primary keys of course_id and student_id should be removed and be utilized as foreign keys. Without first correcting this problem, the CourseMembership model will misbehave.
After that, the CourseMembershipProperty
model should link to the CourseMembership
model by using a foreign key of course_membership_id
. This should work by simply defining the Models as you have in your example since we will be following the CakePHP naming conventions at this point.