title: Dealing with Doctrine2 mapping/relationship in entities
body: <p>I'm working with Doctrine mapping between three entities and some doubts come to me. The entities are <code>Natural</code>, <code>Legal</code> and <code>Orders</code> where one <code>Natural</code> can have many <code>Orders</code> and one <code>Legal</code> can have many <code>Orders</code> too. So in <code>Natural</code> entity I have a <code>OneToMany</code> bidirectional relationship to <code>Orders</code> this is the code:</p>
  
  <pre><code>/**
   * @ORM\OneToMany(targetEntity="Orders", mappedBy="natural")
   */
  protected $orders;
  
  public function __construct()
  {
      $this-&gt;orders = new ArrayCollection();
  }
  </code></pre>
  
  <p>Then at <code>Orders</code> entity I have this:</p>
  
  <pre><code>/**
   * @ManyToOne(targetEntity="NaturalPerson", inversedBy="orders")
   * @JoinColumn(name="natural_id", referencedColumnName="id")
   **/
  protected $natural;
  </code></pre>
  
  <p>Here are my doubts:</p>
  
  <ul>
  <li>Since I have a third entity: <code>Legal</code> should I follow the same procedure in order to make a relationship between <code>Legal</code> and <code>Orders</code>?</li>
  <li>Is not this a serious inconsistency to leave an empty column as the <code>Orders</code> belongs to a <code>Natural</code> or a <code>Legal</code> but not both of them?</li>
  <li>How I save the <code>Orders</code>? I should flush and persist the <code>Orders</code> first and then set the object for <code>Legal</code> or <code>Natural</code> so the method <code>setOrder()</code> should be on <code>Natural</code> and <code>Legal</code> right?</li>
  </ul>
  
  <p>Hope any can help me to understand this and thanks in advance</p>
  
  <p><strong>Proposal DB model</strong></p>
  
  <p>Here is the DB model I have til now, it can be changed</p>
  
  <p><img src="https://i.stack.imgur.com/UD2h2.png" alt="enter image description here"></p>