title: User messaging system
body: <p>I'm looking at creating a user messaging system (similar to Facebook).</p>
  
  <p>What I want to know is essentially what should the table structure look like? The requirements I have are as follows:</p>
  
  <ul>
  <li><p>Messages are exchanged between users - a sender can select multiple users to send a message to.</p></li>
  <li><p>Messages are displayed in a thread-style layout, as a 1-1 conversation. i.e. each recipient's reply will appear in it's own thread.</p></li>
  <li><p>Individual messages cannot be deleted, however a thread can be deleted. Deleting a thread doesn't delete any messages, it just removes that thread from the user's inbox. However the other user can still access the thread if he/she hasn't deleted it from his/her inbox.</p></li>
  </ul>
  
  <p>Here is what I have at the moment:</p>
  
  <pre>
  Table messages
  ==============
  id (PK)
  user_id (from)
  subject
  body
  sent_at
  
  
  Table message_recipients
  ========================
  message_id (PK)
  user_id (PK)
  read_status
  </pre>
  
  <p>EDIT: What about the following:</p>
  
  <pre>
  Table messages
  ==============
  id (PK)
  thread_id   
  user_id (from)
  body
  sent_at
  
  
  Table threads
  =============
  id (PK)
  user_id (from)
  subject
  
  
  Table thread_recipients
  =======================
  thread_id (PK)
  user_id (PK)
  read_status
  sender_deleted
  recipient_deleted
  
  </pre>