RE: Dividing Users

2009-03-21 Thread Dave Maharaj :: WidePixels.com

Thanks John,

It does make more sense. I will give that a try and see how it goes.

Thanks for your detailed feedback.

Dave

-Original Message-
From: John Andersen [mailto:j.andersen...@gmail.com] 
Sent: March-21-09 5:38 AM
To: CakePHP
Subject: Re: Dividing Users


Hi Dave,

Looking at your model, I understand your problem.

As I understand it from your description:
1) A user can have one profile;
2) A user belongs to one group;
3) A user can create one or more ads;
4) A user can create one or more bookmarks;
5) A bookmark refers to one ad;
6) An ad may be referred to by one or more bookmark.

Text version of my data model ( A <-- B means B belongsTo A and A hasMany B;
no indication of mandatory relationships ):
groups <-- users <-- profiles <-- profile_attributes users <-- ads <--
bookmarks users <-- bookmarks profile_types <-- profiles attribute_types <--
profile_attributes.

The major changes from your model are:
1) The ads belongs to a user, not to a profile.
2) The bookmark belongs to a user, not to a profile.
3) One table (profiles) for all profiles, at least the information that are
common for all profiles.
4) Two tables (attribute_types and profile_attributes) for the profile
information, that are not common for all profiles.

So when you model this i CakePHP, and you read a users profile (Agent) then
the model should automatically also read all the profile attributes (using
HasMany relationship) from that model, thus ensuring the correct information
is available for your presentation of the profile (Agent). And the same when
you read a users profile (Investor).

Did this help you?
Best wishes,
John

On Mar 20, 5:56 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> Thanks again for your input. I been trying to get this right and for 
> some reason either I am a complete idiot I just cant get it. Or If it 
> is I do not think its right. I have been playing with it on the 
> cakeapp site to build the tables to give people an 
> idea.http://cakeapp.com/sqldesigners/sql/leiabeans
>
> In my head User belongs to a group (either the INVESTOR or AGENT) 
> Group hasMany Users ok that all makes sense no problems yet
>
> Now because the INVESTOR and AGENT profile information in completely 
> different I want a table for each (INVESTORS and AGENTS), normally 
> USER would have 1 profile but in this case there are 2 options of what 
> profile a USER will have based on the GROUP they are in.
> User hasOne INVESTOR or AGENT (which is a profile) depending on the 
> GROUP they belong to...this is where I am confusing myself. So a USER 
> who belongs to the GROUP AGENT will have a AGENT USER.ID in the 
> table...? Lost myself even trying to write it.
>
> Does this make sense to anyone?
>
> Thanks,
>
> Dave
[snip]


--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dividing Users

2009-03-21 Thread John Andersen

Hi Dave,

Looking at your model, I understand your problem.

As I understand it from your description:
1) A user can have one profile;
2) A user belongs to one group;
3) A user can create one or more ads;
4) A user can create one or more bookmarks;
5) A bookmark refers to one ad;
6) An ad may be referred to by one or more bookmark.

Text version of my data model ( A <-- B means B belongsTo A and A
hasMany B; no indication of mandatory relationships ):
groups <-- users <-- profiles <-- profile_attributes
users <-- ads <-- bookmarks
users <-- bookmarks
profile_types <-- profiles
attribute_types <-- profile_attributes.

The major changes from your model are:
1) The ads belongs to a user, not to a profile.
2) The bookmark belongs to a user, not to a profile.
3) One table (profiles) for all profiles, at least the information
that are common for all profiles.
4) Two tables (attribute_types and profile_attributes) for the profile
information, that are not common for all profiles.

So when you model this i CakePHP, and you read a users profile (Agent)
then the model should automatically also read all the profile
attributes (using HasMany relationship) from that model, thus ensuring
the correct information is available for your presentation of the
profile (Agent). And the same when you read a users profile
(Investor).

Did this help you?
Best wishes,
John

On Mar 20, 5:56 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> Thanks again for your input. I been trying to get this right and for some
> reason either I am a complete idiot I just cant get it. Or If it is I do not
> think its right. I have been playing with it on the cakeapp site to build
> the tables to give people an 
> idea.http://cakeapp.com/sqldesigners/sql/leiabeans
>
> In my head User belongs to a group (either the INVESTOR or AGENT)
> Group hasMany Users ok that all makes sense no problems yet
>
> Now because the INVESTOR and AGENT profile information in completely
> different I want a table for each (INVESTORS and AGENTS), normally USER
> would have 1 profile but in this case there are 2 options of what profile a
> USER will have based on the GROUP they are in.
> User hasOne INVESTOR or AGENT (which is a profile) depending on the GROUP
> they belong to...this is where I am confusing myself. So a USER who belongs
> to the GROUP AGENT will have a AGENT USER.ID in the table...? Lost myself
> even trying to write it.
>
> Does this make sense to anyone?
>
> Thanks,
>
> Dave
[snip]
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Dividing Users

2009-03-20 Thread Dave Maharaj :: WidePixels.com

Thanks again for your input. I been trying to get this right and for some
reason either I am a complete idiot I just cant get it. Or If it is I do not
think its right. I have been playing with it on the cakeapp site to build
the tables to give people an idea.
http://cakeapp.com/sqldesigners/sql/leiabeans

In my head User belongs to a group (either the INVESTOR or AGENT)
Group hasMany Users ok that all makes sense no problems yet

Now because the INVESTOR and AGENT profile information in completely
different I want a table for each (INVESTORS and AGENTS), normally USER
would have 1 profile but in this case there are 2 options of what profile a
USER will have based on the GROUP they are in.
User hasOne INVESTOR or AGENT (which is a profile) depending on the GROUP
they belong to...this is where I am confusing myself. So a USER who belongs
to the GROUP AGENT will have a AGENT USER.ID in the table...? Lost myself
even trying to write it.

Does this make sense to anyone?

Thanks,

Dave


-Original Message-
From: John Andersen [mailto:j.andersen...@gmail.com] 
Sent: March-20-09 4:01 AM
To: CakePHP
Subject: Re: Dividing Users


Yes, the GROUP (group_id) is the same as the ROLE when each user can only
play one role (group)!

So your user model should state that a user HasOne GROUP Your group model
should state that a group HasMany USERs

So when a user with group Seller is selling items with an ad, the ad must be
related to the user, not the group!

Your ad model should state that an ad HasOne SELLER.
Your seller (user) model should state that a seller HasMany ADs

The reason I am using a seller model, is that I then relieve the user model
from taking care of the ad relationship, but it is up to you, how you like
to model your tables.

Hope this helps you on the way :)
   John,



On Mar 19, 5:13 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> 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?
>
[snip]



--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dividing Users

2009-03-20 Thread John Andersen

Yes, the GROUP (group_id) is the same as the ROLE when each user can
only play one role (group)!

So your user model should state that a user HasOne GROUP
Your group model should state that a group HasMany USERs

So when a user with group Seller is selling items with an ad, the ad
must be related to the user, not the group!

Your ad model should state that an ad HasOne SELLER.
Your seller (user) model should state that a seller HasMany ADs

The reason I am using a seller model, is that I then relieve the user
model from taking care of the ad relationship, but it is up to you,
how you like to model your tables.

Hope this helps you on the way :)
   John,



On Mar 19, 5:13 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> 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?
>
[snip]

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Dividing Users

2009-03-19 Thread Dave Maharaj :: WidePixels.com

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:j.andersen...@gmail.com] 
Sent: March-19-09 8:54 AM
To: CakePHP
Subject: Re: Dividing Users




On Mar 19, 7:05 am, Dave  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 PROFILEUSER 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dividing Users

2009-03-19 Thread John Andersen



On Mar 19, 7:05 am, Dave  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 PROFILEUSER 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---