title: How to maintain join node in Firebase db
body: <p>Sorry for the cryptic title.
  I'm new to Firebase db. I'm using it with AngularFire (ng4).
  I'm working on a website about stallions (horses). Each stallion has an owner and an owner can have multiple stallions. Each stallion is also registered with one or more studbooks and a studbook has multiple stallions.
  I now have 3 top-level nodes: stallions, owners and studbooks.</p>
  
  <p>I have a form to add or edit a stallion. This form has select boxes with all possible owners and all possible studbooks. When I save the stallion the whole owner node and the studbook nodes are saved in the stallion node. This part is working fine.</p>
  
  <p>A new page will show the details of the studbook and all its stallions. With this part, I'm struggling. I've read a lot and I think I need a join node (studbook_stallions) where I put in the studbook key and all stallion keys (or whole items?) that are in part of this studbook. I'm a right, so far?</p>
  
  <p>When adding a stallion I can also add an entry in the join node, but what about when modifying a stallion. Do I first need to check if the stallion is already in the join node? Won't this effect performance?</p>
  
  <p>This is my add stallion method:</p>
  
  <pre><code>addStallion(alias: string, formValues: Stallion): any {
    formValues.updated = firebase.database["ServerValue"]["TIMESTAMP"];
    return this.af.database.ref().child("stallions/" + alias).set(formValues);
  }
  </code></pre>
  
  <p>And this is my update stallion method:</p>
  
  <pre><code>updateStallion(alias: string, formValues: Stallion) {
    formValues.updated = firebase.database["ServerValue"]["TIMESTAMP"];
    this.af.object("stallions/" + alias).update(formValues);
  }
  </code></pre>
  
  <p>How to change these methods to also modify the join node (studbook_stallions)?</p>
  
  <p>And a similar question. I now have the whole owner node in my stallion node. How do I update this owner node when I update my owner?
  This is my update owner method:</p>
  
  <pre><code>updateOwner(alias: string, formValues: Owner) {
    formValues.updated = firebase.database["ServerValue"]["TIMESTAMP"];
    this.af.object("stallions/" + alias).update(formValues);
    // Also update in stallion node:
    // ?????????????
  }
  </code></pre>
  
  <p>[<strong>Edit</strong>] </p>
  
  <p>This is my stallion node:</p>
  
  <p><a href="https://i.stack.imgur.com/1JIUM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1JIUM.png" alt="enter image description here"></a></p>
  
  <p>This is my owner node:</p>
  
  <p><a href="https://i.stack.imgur.com/LnikU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LnikU.png" alt="enter image description here"></a></p>
  
  <p>At this moment the stallion node has the full owner data, but the owner node does not yet have the full stallions data. I will change is soon.</p>
  
  <p>I don't yet have modeled the studbook, because I'm not sure what the best workflow is. My studbook will have multiple stallions. When I update my stallion I also need to update the same stallion in the studbook node. But how do I know which stallion in the studbook node? And the same the other way round. I update my studbook and I now need to update the studbook in several stallion nodes.</p>