It should result in the same db structure. Just use appropriate flag attributes in the associative table. When you run your find() you'll want to use conditions to filter on the attributes.
User user_profile: follower, profileowner Profile In data modeling speak, the stucture is physical implementtion of a User Many-To-Many Profile. The 'real' primary key in the user_profile table is user_id+profile_id and both are individually foreign keys (I use 'real' because cake uses id and _id for pkey and fkey by default). You use the relationship (implemented as user_profile) to describe some additional data - if you think about it you can't place owner and follower data in User as they can be multiple entries (dito for Pages), but it fits into user_profile. You'll see a similar type of structure in the ACL component, where aros_acos contains the permissions (_create, _delete etc). With the structure you can answer: - is user A a follower of Profile B - is user A an owner of Profile B - Who are all the owners of Profile B - Who are all the followers of Profile B - What profiles does user A follow - What profiles does user A own - Is an owner also a follower etc. On Jul 15, 6:18 pm, abhishekh <[email protected]> wrote: > Thanks for the input. > > But,the relationship is this way > 1) users HASBTM profiles. > > 1st scenario ) user can have multiple profiles. A profile can belong to > multiple user. > 2nd scenrio ) even if user is not having a particular profile, he can still > follow that profile. > > thats the reason there are 2 HASBTM tables. 1) users_profiles for 1st > scenario 2) followers for 2nd scenario. > > > > womble-2 wrote: > > > I'm only a cake noob, and I obviously don't know for sure about how > > your thinking of Users and Profiles. > > > In my mind: > > User hasOne Profile > > Follower hasAndBelongsToMany Profiles (or prehaps instead of > > Profiles its Users) > > > But User and Follower are essentially the same.... so in my Database > > mind...... > > > User > > user_profile : user_id, profile_id, follower (set either true/false) > > [if you can follow your own Profile then you'd also add: owner (true/ > > false) ] > > Profile > > -- > View this message in > context:http://www.nabble.com/Many-to-Many-relationship-issue-tp24466294p2449... > Sent from the CakePHP mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
