title: Structuring a friend list in a Firebase database
body: <p>I am looking for the best way (or at least the right way) to implement a friend system Firebase database in which each user in the database has his own information (his name, profile picture, email, etc.) and a friend list.</p>
  
  <p>The problem is that I can't think of a good, efficient way to store the information inside the database, for example, if I store the data in the following way -</p>
  
  <pre><code>{
      "users": {
          "johnappleseed": {
              // name, profile picture URL, email, phone, etc...
              "friends": {
                  "alice": true,
                  "bob": true,
                  "james": true,
                  "johnappleseed2": true,
                  // ...
              }
          },
          "johnappleseed2": {
              // ...
          }   
      }
  }
  </code></pre>
  
  <p>and I want the app to show the list of friends of a certain user (which shows the friends' names, profile pictures, etc.) I would still need to perform a server request for <strong>each one</strong> of the friends in the list (while, AFAIK performing lots of server requests is considered a bad practice) to grab whatever information I want to display beyond their username... Also, what happens when a user changes their username?</p>
  
  <p>Can anyone suggest a better solution or a structure that would make more sense?</p>