In my Yii app I have 2 models, Profiles and Groups. Each profile belongs to a Group defined by Profiles.GroupID that is a FK to Groups.GroupID. Also, each Group has a manager (Group.ManagerID) which is basically another profile (therefore, it references a user_id in the table Users).
In model Profiles I would like to define a relation so that, for a given Profile I can easily retrieve the Manager.
Below is some sample data from the two tables that represent the 2 models Profiles, Groups:
Table Profiles
user_id firstname lastname group_id
------- ----------- ---------- -------
1 John Doe 100
2 Walter White 200
3 Gus Fring 100
4 Biggie Smalls 200
Table: Groups
group_id manager_id
------- ---------
100 2
200 4
Any suggestions would be appreciated.