In a way, you're building groups similar to what you'd do for ACL. Based on what you've outlined, I would just have the Invitations belong to a User (sender), and HABTM Users (invitees), and then have another relationship for "Friends" that would belong to a User, and contain the Users that are "Friends".
That said, you could also go for a more generic approach like is used for ACL, and have Users and Groups, where there is a HABTM between Users and Groups, and then have one Group that would be "Friends" of a User, and another group that would be the "Invitees" for an event. You need the join table if the relationship is going to be many-to- many, you can accomplish the same thing without the join table if you denormalize the keys back into the other table (which is typically what you want for one-to-many or one-to-one sorts of relationships). For example, you could have your "Friends" table include a foreign-key for owner_user_id (owner) and another for user_id (friends), which would result in one row in the "Friends" table for each User that is a "Friend". Really depends on the volume of data and how normalized you want to make your data model IMHO. On Nov 30, 5:24 pm, boomswitch <[EMAIL PROTECTED]> wrote: > Hi all, > > New here, new to CakePHP, but loving it so far. > > I'm working on planning a basic invitation application, but I'm > struggling with how to plan my database and some model associations. > > A few things about my current setup: > > - CakePHP 1.2-latest, Apache, MySQL > - I have a working User (authentication) model > > For this invitation system, there are a few seemingly simple > requirements that I'm struggling to design properly within Cake: > > - Users can invite Friends to events. > - Users can invite Users to events. > - Friends are registered users that Users have added to their Friends > list. > > In other words, all persons invited to an event are registered users. > However, some are marked Friends and some aren't. How can I relate > this all properly to the User model? I think I have a few of these > right, but I'm wondering if there's a better way to keep Friends Lists > and also associate both Friends and non-Friends (Users) to > Invitations. > > - Invitations "belongTo" a User (the creator/owner). > - User "hasMany" Invitations. > - Invitations have many invitees which can be Friends or non-Friends > -- all of which are Users. > > How do I store my list of all the invitees for an Invitation? Would I > need an Aquaintances model (for non-Friends that are invited) with an > hasAndBelongsToMany association and use a join table in MySQL? Or > would there be a simpler design... > > Currently, I've got a working Friends List by using a join table that > stores user_id and friend_id. > > All feedback is greatly appreciated, be gentle, I'm new to PHP and > specifically CakePHP. :) > > Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
