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 6233789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:21:49+00:00 2026-05-24T10:21:49+00:00

To frame the question, I’m a designer/front-end developer and looking for some guidance on

  • 0

To frame the question, I’m a designer/front-end developer and looking for some guidance on how to set up my models. I’ve read through the Cake book on associations and HABTM and hasMany through in particular, but still don’t quite understand which is right for my needs.

I’ve built a Cake app with the following models and simple relationships:

User hasMany Workout
User hasMany Shoe
Shoe hasMany Workout

I’d like to allow users to add other users to a workout, so User HABTM Workout. Adding User2 to the workout would create the workout for User2 as well.

I also want User2 to be able to edit the details of the workout for themselves, while maintaining the association (and User1’s details). For example, User2 can specify their own notes or a time for the workout that is different than those specified by User1.

It seems like a HABTM association won’t allow for the User-specific details part, but hasMany through might? Could I do something like this:

User hasMany WorkoutDetail
Workout hasMany WorkoutDetail
User hasMany Shoe
Shoe hasMany Workout

where WorkoutDetail stores all the individual details for each workout for each user?

thanks

  • 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-05-24T10:21:50+00:00Added an answer on May 24, 2026 at 10:21 am

    Yes, your second solution would work well, that is how I usually do HABTM relations when there is extra information to be stored in the join table.

    User hasMany WorkoutDetail
    Workout hasMany WorkoutDetail
    

    One more thing you could add is

    WorkoutDetail belongsTo User
    WorkoutDetail belongsTo Workout
    

    This way, if you query the WorkoutDetail table, you get the User and Workout information along with it.

    And like you said, each user should have a seperate entry in the WorkoutDetail table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question: Can a swing frame be completely modal ( block all others windows
As per the question. In the debug view, there's the Variables frame. It shows
This question isn't meant as flame-bait! As it might be apparent, I've been looking
In a frame I have two columns. In the first column I display some
Not 100% sure how to frame this question but here goes... I currently work
I have a basic question about starting a frame-by-frame animation. When I call the
The quick question: is there a pure PHP library that can extract a frame
I'm trying to use a frame-buster-buster, as discussed in this question: Frame Buster Buster
This question has some relation to this post I made recently: Drag a UIView
Ok, I really don't know how to frame the question properly because I barely

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.