title: SQL Management Studio 2012 Foreign Key Is A Mess
body: <p>I am trying to add a foreign key to a table. I have created two tables.</p>
  
  <pre><code>CREATE TABLE madeupbusiness.staff
  (
  staffnum int NOT NULL,
  forename varchar(30) NOT NULL,
  surname varchar(30) NOT NULL,
  meeting int NOT NULL,
  PRIMARY KEY (staffnum),
  )
  GO
  </code></pre>
  
  <p>meeting should use the PK from from the meeting table to create a FK :</p>
  
  <pre><code>CREATE TABLE madeupbusiness.meeting
  (
  meetingnum int NOT NULL,
  room varchar(30) NOT NULL,
  PRIMARY KEY (meetingnum),
  )
  GO
  </code></pre>
  
  <p>To create the foreign key I run this query</p>
  
  <pre><code>ALTER TABLE madeupbusiness.staff
  WITH CHECK
  ADD CONSTRAINT FK_staff_meetingnum FOREIGN KEY (meetingnum)
  REFERENCES madeupbusiness.meeting(meetingnum)
  ON DELETE CASCADE
  ON UPDATE CASCADE
  ;
  GO
  </code></pre>
  
  <p>The query runs but when I create a database diagram there is a square loop the staff table from the staffnum key back onto it. Sorry but I don't really know how to describe it. There is no relationship between the two tables. What am I doing wrong?</p>
  
  <p>I have tried to add the relationship from design view but the foreign key table is greyed out.</p>