title: Firebase data structure for performance vs querying
body: <p>I'm debating on data structures. I have a list of items that can either be <code>public</code> or <code>per-user</code>. Here are my 2 options</p>
  
  <pre><code>//1
  items: 
     item1 { authorId: "system"  }
      item2 { authorId: "user1"  }
  
  //2
  items: 
      system
            item1 {   }
      user1
            item2 {  }
  //3
  items: 
     item1 { }
     item2 { }
  
  user-items: 
     system { items: {item1: true} }
     user1 {  items: {item2: true}  }
  </code></pre>
  
  <p><strong>Structure 1</strong>:</p>
  
  <ul>
  <li>harder to query</li>
  <li>I don't need to know the type of an item to query it (all i need is id)</li>
  </ul>
  
  <p><strong>Structure 2</strong>:</p>
  
  <ul>
  <li>Easier to query</li>
  <li>Possibly better performance</li>
  <li>I need to know whether an item is public or per user to be able to query it</li>
  </ul>
  
  <p><strong>Structure 3</strong>:</p>
  
  <ul>
  <li>More flexible</li>
  <li>Requires multiple queries to fetch expected data (fetch user-items, fetch item ids, and then for each id fetch the item)</li>
  </ul>
  
  <p>Any recommendations?</p>