title: Firebase data structure for one to one chat
body: <p>I'm implementing one to one chat in firebase. I'm bit confuse with the data structure. There is best practice available for <a href="https://firechat.firebaseapp.com/" rel="nofollow">firechat</a>, but that's for group chat not for one to one chat. </p>
  
  <p>I've design the following data structure, Can anyone suggests the better way or point correction.</p>
  
  <pre><code>chat-messages/
     &lt;chat-id&gt;
       &lt;message-id&gt;
          userId - The id of the user that sent the message.
          name - The name of the user that sent the message.
          message - The content of the message.
          timestamp - The time at which the message was sent.
  
  chat-metadata/
     &lt;chat-id&gt;
          createdAt - The time at which the room was created.
          createdByUserId- The id of the user that created the room.
          id - The id of the room.
  
  my-chats/
    &lt;user-id&gt;
       &lt;other-user-id&gt;
          chatId - The chat id
  
  users/
    &lt;user-id&gt;
          id - The id of the user.
          name - The display name of the user.
  </code></pre>
  
  <p>In <code>my-chats</code> it will show the all of people user has done chatting. So for username1 and username2 there will be each entries for respective user like</p>
  
  <pre><code>my-chats
    username1
      username2
         chatId:-K6OqUkJRDpnOahGQ4rO
    username2
      username1
         chatId:-K6OqUkJRDpnOahGQ4rO
  </code></pre>