Thanks for your info.

Just wondering because instead of ROLE I have group_id in the USER table so
each user is either a 1 2 or 3 (MANAGER, BUYER or SELLER) is that not the
same thing? 

-----Original Message-----
From: John Andersen [mailto:[email protected]] 
Sent: March-19-09 8:54 AM
To: CakePHP
Subject: Re: Dividing Users




On Mar 19, 7:05 am, Dave <[email protected]> wrote:
> Can someone tell me if this would be the correct structure for 
> database table names?
>
> Everyone is a USER :which has (ID, name, password, email, group_id)
>
> USERS are broken up into 3 GROUPS (ID, name)
>
> So the USER then fits into one of the GROUPS below
>
> MANAGERS(id, user_id, name, .......)
> BUYERS (id, user_id, name, .......)
> SELLERS (id, user_id, name, .......)
>
> Now a SELLER would be selling ITEMS so when they make an ad is it 
> using the USER_ID or SELLER_ID? or if a BUYER would be looking for  
> ITEMS so when they make an ad is it using the USER_ID or BUYER_ID?
>
> Because if I used USER_ID would that not make it more difficult later 
> when a SELLER and BUYER are in the same table?
>
> Just trying to figure out if everything should be associated to the 
> USER ID or use the ID based on the group they belong to?
>
> Just like a PROFILE....USER can only have one and its either as a 
> BUYER or SELLER.
>
> user model::
> var $hasMany = array(
>                         'Manager' => array('className' => 'Manager',
>
> 'foreignKey' => 'user_id',
>
>                         ),
>                         'Buyer' => array('className' => 'Buyer',
>                                                                 
> 'foreignKey' => 'user_id',
>
>                         ),
>                         'Seller' => array('className' => 'Seller',
>                                                                 
> 'foreignKey' => 'user_id',
>
>                         )
>         );
>
> But that is not right either is it? Because the user only hasOne. Cant 
> be a buyer and a seller.
>
> Can someone point out my error in thinking.

To identify a user you will always use the USER.ID

If a user can only play one role (Manager, Seller, Buyer) then you need only
a column in the USER entity to state that, for example USER.ROLE.

If a user can play more than one role, then you need a ROLE entity and a
USER ROLE entity, where the ROLE entity contains the list of possible roles
(Manager, Seller, Buyer, etc.) and the USER ROLE entity contains the users
roles (USER ROLE.USER ID, USER ROLE.ROLE ID), one record for each role
assigned to a user.

Hope this helps you on the way :)
   John



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to