title: MongoDB schema design: songs/plays/likes
body: <p>This is my first project using a NoSQL database and I am wondering how to structure my data in the most efficient way.</p>
  
  <p>I am making a small service which stores all songs played by a radio station. Users can "like" the songs. So, basically I have the following data:</p>
  
  <pre><code>Song: Id, Artist, Title
  Play: SongId, Time (when was the song played)
  Like: SongId, UserName, Time (when did the user click the like button)
  </code></pre>
  
  <p>I need to run various queries on that data. For example: last X songs played + like count, top played songs in the last X days, who liked a specific song etc.</p>
  
  <p>First I was thinking about storing everything in a single document with nested play and like information. But this makes some of the queries quite complicated and requires me to do stuff like sorting on the client side but I would like to keep the amount of data transfered from the database small.</p>
  
  <p>I was also thinking about caching some of the most used queries in memory. Are there any general recommendations when doing something like that?</p>