<dave@widepixels.com> wrote:
> This is fairly simple question but I think saying it in my head and hearing
> it sounds wrong and confusing me further.
>
> "User" signs up and selects the "Group" they are going to belong to as they
> can only belong to one group...sounds fine when you say it out load
> "Group" has many "Users".....sounds fine when you say it out load
>
> User belongsTo Group
> Group hasMany Users
>
> -- OR --
>
> "User" signs up and selects the "Role" they are going to have as they can
> have only 1 role sounds fine when you say it out load
> "Role" has many "Users' sounds wrong....
>
> User hasOne Role
> Role hasMany Users
>
>
> So my question is how should this go?
I understood what did you mean. But we don't have to
think in "Role hasMany User" as in ownership thought.
The "rule of thumb" is that the model that has a foreignKey
to another "belongsTo" that model, i.e., if the "User" needs
to know your Role, so the users table must have a role_id,
so "User belongsTo Role" and "Role hasMany (or even
hasOne if that's the case) User".
Got it? :-P
Best regards.
--
MARCELO DE F. ANDRADE
Belem, PA, Amazonia, Brazil
Linux User #221105
http://mfandrade.wordpress.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment