title: Building a social network using Firebase
body: <p>I'm currently developing basic social network Android app for sharing images. Already have PHP/mySQL back-end but thinking about migrating to Firebase because of some features that I like (e.g. security, fast read/write).</p>
  
  <p>So, I have <code>users</code>, <code>posts</code>, <code>followers</code>, <code>likes</code>, <code>comments</code> (like every other social network nowadays).</p>
  
  <p>Long story short, I want to know if I'm getting this right. 
  According to <a href="https://firebase.google.com/docs/database/android/structure-data#fanout" rel="nofollow noreferrer">this Firebase documentation</a> and its example I should include unique keys from some JSON trees to others like this (example from documentation):</p>
  
  <pre><code>// An index to track Ada's memberships
  {
    "users": {
      "alovelace": {
        "name": "Ada Lovelace",
        // Index Ada's groups in her profile
        "groups": {
           // the value here doesn't matter, just that the key exists
           "techpioneers": true,
           "womentechmakers": true
        }
      },
      ...
    },
    "groups": {
      "techpioneers": {
        "name": "Historical Tech Pioneers",
        "members": {
          "alovelace": true,
          "ghopper": true,
          "eclarke": true
        }
      },
      ...
    }
  }
  </code></pre>
  
  <p>Does this mean that I will have to include keys from posts, comments, followers etc. to my users tree like this:</p>
  
  <pre><code>{
    "users": {
      "alovelace": {
        "name": "Ada Lovelace",
        "profileImage": "http://blabla.bla?xyzooqlL.png",
        "about:" : "Exit light, enter night",
        "country": "Neverland"
        // Index Ada's posts in her profile
        "posts": {
           // the value here doesn't matter, just that the key exists
           "post123": true,
           "post234": true
        },
        // all comments this user wrote
        "comments": {
           "comment123": true
        },
        // all posts this user liked
        "likes": {
           "post123": true
        },
        "followers": {
           "user123": true,
           "user234": true
        }
      },
      ...
    },
    "posts": {
      "post123": {
        "image": "www.bla.bla/sadsadsa.png",
        "description": "Hue hue hue",
        "likes": {
          "alovelace": true,
          "ghopper": true,
          "eclarke": true
        },
        "comments": {
          "comment123": true,
        }
      },
      "post234": {
       "image": "www.bla.bla/233arweeq.png",
        "description": "This is nice",
        "likes": {
          "eclarke": true
        },
        "comments": {
          "comment234": true,
        }
      },
    "comments": {
      "comment123": {
        "userId": "alovelace"
        "text": "cool",
        "date": "current"
      }
     },
      ...
    }
  }
  </code></pre>
  
  <p>Isn't it a little too much if I have for example 5000 followers, 2000 followings, 1500 post likes? <strong>When fetching user or any other object I will also fetch all its keys within that object</strong>. Imagine fetching 15 very active users with all this data.</p>
  
  <p>If you have any suggestions how should I structure data, please let me know. <strong>Any kind of feedback will be useful.</strong></p>
  
  <p>Thanks.</p>