Off the top of my head ...

users
- id
- name
- email

messages
- id
- created
- subject
- content

inboxes
- id
- user_id

outboxes
- id
- user_id

inboxes_messages
- inbox_id
- message_id

messages_outboxes
- message_id
- outbox_id

User hasOne Inbox, Outbox

Better might be to have several for each user:
User hasMany Inbox, Outbox

Inbox HABTM Message HABTM Inbox
Outbox HABTM Message HABTM Outbox

So, to "delete" a message, you simply remove the appropriate record in
the join table. The Message, itself, is left in place and there's just
one copy in the DB.

On Wed, Sep 23, 2009 at 4:58 AM, invisibleman <[email protected]> wrote:
>
> I need some help in creating the right tables for a private messaging
> system for cakephp. Can anyone help.
>
> Basically at the moment i have the following tables
>
> Users
> - id
> - name
> - email
>
> Messages
> - id
> - subject
> - body
> - datesent
>
> MessageFolders
> - id
> - foldername
> - status
>
> The messagefolders table contains inbox and outbox i need to link the
> users, messages and messagesfolders tables together but what i need
> practically is for a message to be stored in the sending users outbox
> and in the receiving users inbox but both users are able to delete
> their messages but it should not effect the other user.
>
> E.g if i sent a message to a user and i delete it from my outbox the
> recipient user should still have the message in their inbox.
>
> I'm not sure if there should be 2 copies of the message or some status
> field as to whether a user can see it or not.
>
> I'm just looking for some guidance, Any help much appreciated
>
> >
>

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