Heres what I was thinking:

User hasOne Profile - Profile is a factory model that loads
StaffProfile, ManagementProfile or CustomerProfile,
AccountAdminProfile, AccountManagerProfile, BillingContactProfile.
The profile model can hold all the common data (address, phone etc)
and the specific profile holds all the extra data, but doing this will
require some extra associations e.g. XXXProfile belongsTo Profile.  If
the profile_id in the user table is not set then you obviously won't
be loading any Profile data.  This is very close to what you have with
the staff_members and managment_members tables. Just call a Profile a
Member and I think you have the db structure.  YOu do not need a
profile for every user type if you don't want - you could get away
with InternalProfile and ExternalProfile or whatever you think is
appropriate.

Customer hasMany Accounts - a customer is a User with a
CustomerProfile

Account belongsTo AccountAdmin(admin), AccountManager(manager_id),
BillingContact(billing_contact_id)  (which are users)

I would keep the accounts table the way you have it now as I think the
above associations is more correct than User belongsTo Account.

Man I love complex data models and associations.  There are so many
different ways you can model them and everyone has a different idea as
to waht is correct.  Feel free to say that eveything I just wrote is
crap and wont work in your situation. :)

Geoff
--
http://lemoncake.wordpress.com



On Aug 8, 6:20 am, "Sonic Baker" <[EMAIL PROTECTED]> wrote:
> Hi Geoff,
>
> Thanks very much for your response. Just got to view it now. I'll have a
> look into your suggestions but they sound good.
>
> On 8/2/07, Geoff Ford <[EMAIL PROTECTED]> wrote:
>
> > I hope this seems clear enough.
>
> On the permissions and profiles, I think so. Just to clear another part up;
> Am I right thinking that the `users` table will have an 'account_id' which
> is only set if the user is an account user. This can be used in the factory
> method for "Account Users" and ignored in the factory method for "System
> Users". Or can you suggest a better way?
>
> The way it is at the moment; the `accounts` table has fields for the Billing
> Contact's name, email, and phone number as well as similar fields for the
> account owner (admin) and manager. I could still just leave the
> 'billing_contact_id' and 'manager_id' in the `accounts` table but there
> wouldn't be any need if I had the 'account_id' in the users table.
> However this setup would imply that it's possible for an Account have Many
> BillingContact's and Managers etc.. whereas the current setup is more hasOne
> oriented. I suppose I could restrict it to one in my application logic. Any
> thoughts?
>
> Thanks again for your help,
>
> Sonic


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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