Err, dunno why I put varchar(255) for those ids, they are obviously int (10) instead
On Dec 1, 10:24 pm, boomswitch <[EMAIL PROTECTED]> wrote: > Hi, > > Thanks for the response. > > So to clarify your first idea -- would my model associations look > something like this? > > - Invitations belongTo Users (senders/creators). > - Invitations haveAndBelongToMany Users (invitees) > - Friends belongTo Users > > One issue I'm seeing with all this is invitees are often not > registered users, but just a bunch of email addresses. Once they get > the invite, they have to register, but does that change the > associations or models much? I am thinking I could have an "active" > field in my Users model/table that puts all fields to null except > their email address, then when they hit the invite link and register > their username/password, they become "active". > > I think this will all work right so long as the Friends belongTo Users > association can be pulled off. I have a table right now that is > similar to what you described, but it's like this > > user_id, varchar(255) > friend_id, varchar(255) > > so if user 'john_doe' has user_id in the Users table of 1, and he has > 3 friends with different user_ids, the table users_friends would look > like: > > user_id | friend_id > ============== > 1 | 7 > 1 | 12 > 1 | 19 > > and so on. > > Your ACL Groups idea is interesting. Any suggested reading for that > 'generic' setup? Sounds more simplified, but I'm not sure how the > database tables and model associations would compare to the first idea > I've outlined. > > Thanks again > > On Dec 1, 1:04 pm, Rob <[EMAIL PROTECTED]> wrote: > > > 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 -~----------~----~----~----~------~----~------~--~---
