title: How to define foreign key relationships in sails with mysql
body: <p>I'm really new to sails and all of the documentation to do with ORM is about as basic as you could get, so I'm struggling to understand how to set up relationships in my models. Here are my tables and models: <a href="http://pastebin.com/yt8jFTkk" rel="nofollow">http://pastebin.com/yt8jFTkk</a></p>
  
  <p>Now, what I'm trying to do is something like:</p>
  
  <pre><code>AccountApplication.findOne({
      token: 'someTokenHere', 
      application.type: 'foo', 
      application.serviceProvider: 'bar'
  }).populate('application')
  .populate('account').exec(...)...
  </code></pre>
  
  <p>I would settle for this and manually check for the expected application type and service provider as token overlap seems pretty improbable and use a find() instead of findOne():</p>
  
  <pre><code>AccountApplication.findOne({
      token: 'someTokenHere'
  }).populate('application')
  .populate('account').exec(...)...
  </code></pre>
  
  <p>I guess I'm at a bit of a loss as to how sails / waterline is to know that the the account_id on my AccountApplication model is the foreign key for the account property. What am I missing here? Currently populate() on either account or application are doing nothing using the models above.</p>