title: How to "extend" models with data in CakePHP properly?
body: <p>I am rewriting an old hand-crafted-app of mine into CakePHP 2.0, and I bump into this old, ever-repeating Model design dilemma.</p>
  
  <p>This is the target design:</p>
  
  <ul>
  <li>Order has many OrderEntries</li>
  <li>OrderEntry has fields [amount, type]</li>
  <li>ProductEntry extends OrderEntry with fields [product_id, quantity, weight]</li>
  <li>ShipmentEntry extends OrderEntry with fields [total_weight, country_id, city, address, etc.]</li>
  <li>DiscountEntry extends OrderEntry with fields [discount_code, parent_order_id, active, etc.]</li>
  </ul>
  
  <hr>
  
  <p><em>EDIT: Radically simplifying question in lieu of new knowledge</em></p>
  
  <p>So basically, I need this model structure from Cake:</p>
  
  <pre><code>Order        1:m   OrderEntry
  OrderEntry   1:1   ProductEntry
  OrderEntry   1:1   ShipmentEntry
  OrderEntry   1:1   DiscountEntry
  </code></pre>
  
  <p>The last 3 associations should be non-identifying. To be more accurate, one OrderEntry record can have exactly one relation to one of three child models.</p>
  
  <p>This could be achieved by using OrderEntry as a join table between Order and all 3 XxxEntry models, but this means that order_entries table should then have 3 foreign key fields:</p>
  
  <ul>
  <li>product_entry_id</li>
  <li>shipment_entry_id</li>
  <li>discount_entry_id</li>
  </ul>
  
  <p>This is the best solution I have so far, but it's not ideal, since there is a possibility of one Entry being associated to many Orders, which would be an error. Also, one joinTable is holding 3 foreign keys (and thus 3 associated models), which cannot be "NOT NULL", since only one should be filled while other 2 stay null for each record.</p>
  
  <p>To conclude, what is the best practice for having a basic model, which is extended by several different models with their own tables?</p>