title: Foreign keys, where they belong depending on relationships
body: <p>I've worked with databases a fair bit (<em>MySQL, Oracle</em>) though typically only DML as the systems had been previously engineered.</p>
  
  <p>I'm working on a project as the sole developer, and am responsible for application development, and DBA; the latter of course proving more problematic.</p>
  
  <p>In any case - I need a refresh on foreign key constraints, and their logical placement in a model. Given the following:</p>
  
  <pre><code>dbc_user
      .user_id INT, Primary Key, Auto Increment
      // arbitrary columns
  
  dbc_user_profile
      .user_id INT, Primary Key
      // arbitrary columns
  </code></pre>
  
  <p>These tables are a <strong>1-to-1</strong> relationship. I understand that given that relationship, their columns could be consolidated into a single table, but let's just keep them separate. The foreign key belongs then, in the <code>dbc_user_profile</code> table?</p>
  
  <p>What about <strong>many-to-many</strong>?</p>
  
  <pre><code>dbc_user
      .user_id INT, Primary Key, Auto Increment
  
  dbc_city
      .city_id INT, Primary Key, Auto Increment
  
  dbc_user_city
      .city_id INT, Primary Key
      .user_id INT, Primary Key
  </code></pre>
  
  <p>Which tables are the referencing/referenced tables?</p>
  
  <p>For some reason I can't seem to find a quick and dirty tutorial on this, that explains the relationships.</p>
  
  <p>So two part question; </p>
  
  <ul>
  <li>Can someone suggest a tutorial for the semi-savvy that hammers out the details of DDL with regard to foreign keys? or;</li>
  <li>Can someone give a quick rundown on <strong>1-to-1</strong>, <strong>1-to-m</strong>, and <strong>m-to-m</strong> relationships and FK references?</li>
  </ul>