title: Inverting the data structure using backbone relational
body: <p>I'm using backbone-relational to write an app using nested data. The top level of the data structure contains most of the data (in terms of MB) but is never used as a standalone item; it's only used to flesh out the attributes of its related children (flyweight pattern?).</p>
  
  <p>To send all this data to the browser I'm using something like the following data structure</p>
  
  <pre><code>records = [ 
     {performerName: 'Jane', details: {composerName: 'Beethoven', ... }}, 
     ... 
  ] 
  </code></pre>
  
  <p>And this is then encapsulated by two models, <code>Piece</code> and <code>Performance</code> - both inherit from Backbone.RelationalModel but only <code>Performance</code> has a relation defined as follows</p>
  
  <pre><code>relations: [
      {
          type: 'HasOne',
          key: 'piece',
          relatedModel: 'Piece',
          reverseRelation: {
              key: 'performances'
          }
      }
  ],
  </code></pre>
  
  <p>and then a performances collection can be built straight from the original JSON.</p>
  
  <p>This all works fine, but the problem is that I'm sending several copies of the data for each <code>Piece</code> (as each piece typically has several performances) so the download size is a lot bigger than it needs to be.</p>
  
  <p>What's the best way to send a lighter weight data structure ( as below or some other structure that avoids masses of duplication) and yet still have relatively painless creation of the performances collection I need to work with.</p>
  
  <pre><code>records = [ 
     {composerName: 'Beethoven', ..., performances: [array of jsons, one for each performance] 
     ... 
  ] 
  </code></pre>