title: Writing Migrations with Foreign Keys Using SequelizeJS
body: <p><strong>The Background</strong></p>
  
  <p>I'm building a project with <a href="http://sequelizejs.com" rel="noreferrer">SequelizeJS</a>, a popular ORM for NodeJS.  When designing a schema, there appears to be two tactics:</p>
  
  <ol>
  <li>Create model code and use the .sync() function to automatically generate tables for your models.</li>
  <li>Create model code and write <a href="http://sequelize.readthedocs.org/en/latest/docs/migrations/" rel="noreferrer">manual migrations</a> using <a href="https://github.com/sequelize/sequelize/blob/master/lib/query-interface.js" rel="noreferrer">QueryInterface</a> and <a href="https://github.com/sequelize/umzug" rel="noreferrer">umzug</a>.</li>
  </ol>
  
  <p>My understanding is that #1 is better for rapid prototyping, but that #2 is a best practice for projects that are expected to evolve over time and where production data needs to be able to survive migrations.</p>
  
  <p>This question pertains to tactic #2.</p>
  
  <p><strong>The Question(s)</strong></p>
  
  <p>My tables have relationships which must be reflected through foreign keys.</p>
  
  <ul>
  <li><p>How do I create tables with foreign key relationships with one another through the Sequelize QueryInterface?</p></li>
  <li><p>What columns and helper tables are required by Sequelize? For example, it appears that specific columns such as createdAt or updatedAt are expected.</p></li>
  </ul>