title: Tables for orders
body: <p>I'm having a very difficult time setting up model/table relationships for a hobby project I'm working on. What I have is an order, the order will have one or many packages, each package has one or many products, each product will have one area it is assigned to. There can be multiple of the same product on the order and in the same package but each will have a different area
  and a different quantity. I'm struggling to determine how the relationships are set up. </p>
  
  <p>At the end of the day I need to run a report that shows me the order details listing all packages on the order and all the products and areas contained in each package. I also need a report that shows me the order and a sum of all the quantities for each product on the order (no packages on this one). I'm using Rails ActiveRecord I think believe there will be a couple polymorphic relationships, but I'm struggling to identify them as this is outside of my simple "everything has a one-to-many relationship" thinking.</p>
  
  <p>How can I put these tables together in an intelligent manner? I have searched for similar schema diagrams without much success.</p>
  
  <p><a href="https://i.stack.imgur.com/embYe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/embYe.png" alt="enter image description here"></a></p>
  
  <p>This is the basics of what I am thinking of for relationships, but I'm not sure what the Rails models will look like. It seems like every relationship from orders down is polymorphic; how do I nest these relationships in Rails?</p>