title: T-SQL: foreign key that's not referencing a primary key
body: <p>I have the following database:</p>
  
  <pre><code>CREATE TABLE ContentNodes
  (
     Id UNIQUEIDENTIFIER NOT NULL, 
     Revision INT IDENTITY(1,1) NOT NULL,
     ParentId UNIQUEIDENTIFIER NULL
     PRIMARY KEY (Id, Revision)
  )
  </code></pre>
  
  <p>How do I limit ParentId to only contain values from the Id column. Trying to make ParentId a foreign key gives me:</p>
  
  <pre><code>PRINT 'FK_ContentNodes_ParentId_ContentNodes';
  ALTER TABLE ContentNodes
  ADD CONSTRAINT FK_ContentNodes_ParentId_ContentNodes FOREIGN KEY (ParentId) REFERENCES ContentNodes(Id);
  GO
  </code></pre>
  
  <p>Error:    </p>
  
  <blockquote>
    <p>There are no primary or candidate keys in the referenced table
    'ContentNodes' that match the
    referencing column list in the foreign
    key
    'FK_ContentNodes_ParentId_ContentNodes'.</p>
  </blockquote>