title: Adding foreign keys to an already existing database
body: <p>I'm trying to export data from an Excel spreadsheet into a fairly complex relational database.  The spreadsheet indicates "foreign keys" by stating the names of other objects.  (Luckily, I have some control over the spreadsheet, so I can guarantee these names are unique AND that the objects they reference actually exist).  </p>
  
  <p>I have a program that can recreate these tables in a MSSql database, but it can't automatically link them to each other.  Besides, I don't want to use the actual names of the objects as the primary key since eventually the database will be large.</p>
  
  <p>So, if I have many existing but unconnected tables which refer to each other by their "name" fields, how can I add a foreign key that links them by their IDs?</p>
  
  <p>A simplified version of what I have:</p>
  
  <pre><code>Parent
  ID: 1 (PK)
  Name: Mary
  
  Child
  ID: 2 (PK)
  Name: Jane
  ParentName: Mary
  </code></pre>
  
  <p>And what I want to achieve:</p>
  
  <pre><code>Child
  ID: 2 (PK)
  Name: Jane
  ParentID: 1 (FK)
  </code></pre>
  
  <p>Thanks for any help!  I wasn't able to find an example of how to add a foreign key mapping after the fact, or on a different field.</p>