Hi All,
I am confused about how to set this up using Cake's conventions. I have a table of users (pretty standard: id (pk, auto-increment), username, password), a table of groups (also pretty standard: id, name, user_id) and a practice table (like a doctor's practice, not like "practice makes perfect"). The practice table will be owned by one user (that belongs to a dr group) and will zero or more other users that belong to the practice (and are standard members).
here's a very rough drawing of what I am thinking:
user ---(belongs to)---> group
|
|
+<----(belongs to)---- practice
| ^
| |
+-------------------(belongs to)
I understand how to make sure that only members of group "caretaker" can own a practice and I know how to make sure that each user has one group and all of that.
Normally I would understand how to make "practice has many user" and "practice belongs to user". Where I'm getting stumped, though, is how do I specify that a practice "has one" user but also "has many" users. This is because the practice doesn't know the groups that a user belongs to in Cake. And (to my knowledge), I can't just say "practice.owner_id is a foreign key that matches user.id" because Cake won't understand this.
If I am mistaken, can you please provide an explanation/link to a doc to help me on my way? Thanks SO.