title: Database design - Follow System of billions of records
body: <p>I am working on a social android application that have the same followers system like <strong>soundcloud</strong>. <br>
  <br>
  I know that it can be implemented easily like this in <strong>MySQL</strong>, a follow table that hold both the follower and the one he followed</p>
  
  <pre><code>follower_id   following_id
  1             2
  4             1
  6             2
  9             6
  .             .
  .             .
  .             .
  </code></pre>
  
  <p>and use both ids as a primary key.</p>
  
  <p><strong>But the problem is</strong> We are expecting the network to grow to millions of users. <br></p>
  
  <p>Imagine only 1 million users that for average everyone would have 500 followers and following 500 persons. </p>
  
  <p>That will result in a table of about <strong>1,000 * 1,000,000 = 1,000,000,000 records</strong> and that will continue to grow! <br></p>
  
  <p>Could <strong>MySQL</strong> perform well in such circumstances? <br><br>
  I could use <strong>MongoDB</strong> and store it like this</p>
  
  <pre><code>user_id     followers                                   following
  1           [embedded documents holding followers]       [embedded documents holding following]
  2           [embedded documents holding followers]       [embedded documents holding following]
  3           [embedded documents holding followers]       [embedded documents holding following]
  ...  
  </code></pre>
  
  <p><strong>The problem here</strong> is not the performance - as i think - but will be that <strong><em>mongo doesn't support Transactions</em></strong> because for every following action I should store it in 2 documents!</p>
  
  <p>So, what do you think is the best approach to do this? Could MySQL perform well if table grow to be billions of rows?!! Is there any other efficient design?!</p>