title: Data Model Design
body: <p>I'm a bit stuck designing the data model for my iOS app. I'm using <a href="https://parse.com/" rel="nofollow noreferrer">Parse</a> as my backend service which has two data classes: <code>Songs</code> and <code>Ratings</code>(user ratings). When my app launches, I'm currently making 5 separate queries to Parse that make up 5 possible data sources for my UITableView:</p>
  
  <ol>
  <li>mainQuery - daily uploaded songs</li>
  <li>topTracksOfTheWeek - top rated songs of the week</li>
  <li>topTracksOfTheMonth</li>
  <li>topTracksAllTime</li>
  <li>userRatedTracks - songs the user rated</li>
  </ol>
  
  <p>Parse makes it easy to add constraints to the query to return the desired data. However, I also need to compare <code>userRatedTracks</code> to each of the other queries and embed the <code>userRating</code> into each datasource if it exists for each track. (which I learned how to do effectively here: <a href="https://stackoverflow.com/questions/12397483/efficient-looping-in-objective-c">Efficient looping in objective-c</a></p>
  
  <p>I'm having trouble figuring out how optimize or change this design for better performance. All of the above queries are called in a method <code>getDataSource</code> which is called in <code>viewDidLoad</code> and then a method <code>assignDataSource</code> sets the table's data source array depending on which data source the user has selected (<code>mainQuery</code> being the default). Ideally, on app launch <code>mainQuery</code> is fetched on the main thread, populates the table, and the other queries are fetched in a background thread. However, this would be inefficient if the user selects to view the <code>topTracksOfTheWeek</code>. When <code>getDataSource</code> is called and <code>topTracksOfTheWeek</code> query doesn't have priority. </p>
  
  <p>The easy way to go would be to lazily load each query as I need them, but I'm worried this will hinder the responsiveness of the app compared to loading all the data initially. </p>
  
  <p>As you can probably tell, I'm a beginner. I find design patterns to be extremely frustrating as a beginner because I always think there is a better way to structure code than the way I'm doing it. Does anyone have any advice on design with multiple data sources?</p>