I am developing a resume app and have created a table called areas using the CakePHP Tree Behaviour. In this table, I have a bunch of countries and cities.
The original purpose of this table was to allow users to specify which areas they are interested in working in on their resume. This is pretty straightforward and I have created a HABTM relationship between users and areas to deal with this.
However, the next thing I need to do is allow users to specify where they are from. Of course, I could create a new table, identical to areas and call it something different, but this seems a bit wasteful and inefficient.
So, I am wondering if it is actually possible to have two totally different associations between the users table and the areas table?
In other words, the users table would have-and-belong-to-many areas (for the purpose of users specifying all of the areas they are interested in working in in the world) but it would also have-one area (for the purpose of users specifying which country they are from).
I can’t begin to imagine how to go about properly setting up the models according to CakePHP convention — or whether it is even a good idea to attempt this — so I would appreciate any pointers anyone can give.
I am also happy to hear people’s opinions even if the answer is not CakePHP-specific because this is more of a database question than anything else.
You can specify any association you want.
for example in your user Model: