Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9122391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:05:38+00:00 2026-06-17T06:05:38+00:00

I am developing a resume app and have created a table called areas using

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:05:39+00:00Added an answer on June 17, 2026 at 6:05 am

    You can specify any association you want.

    for example in your user Model:

    /**
     * @see Model::$hasAndBelongsToMany
     */
        public $hasAndBelongsToMany = array(
            'Area' => array(
                'className' => 'Area',
                'joinTable' => 'user_areas',
                'foreignKey' => 'user_id',
                'associationForeignKey' => 'area_id',
            ),
        );
    
    /**
     * @see Model::$hasOne
     */
        public $belongsTo = array(
            'Farea' => array(
                'className' => 'Area',
                'foreignKey' => 'farea_id',
            ),
        );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a iOS app in which I am using Core Data. I
Developing an app for iOS, I need to know how to have instanced and
I am developing an Android app using fragments and would like the user to
I am developing an app and have been able to start a phone call
I am developing a cocos2d IPhone app using the SimpleAudioEngine to play some mp3
I'm developing an app which contain TabHost ,in one of those tabs i have
I am developing an app using parse.com API (hosted backend which provides API to
After months of developing I realize that my app (only using android 2.1) crashes
Developing for Android 2.3, I have a question regarding layouts. I use a vertival
Developing a project of mine I realize I have a need for some level

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.