title: Primary & Foreign Key Constraints Confusion
body: <p>currently trying to apply foreign keys to my created tables but I'm getting the SQL error: </p>
  
  <pre><code>SQL Error: ORA-02270: no matching unique or primary key for this column-list
  02270. 00000 -  "no matching unique or primary key for this column-list"
  *Cause:    A REFERENCES clause in a CREATE/ALTER TABLE statement
         gives a column-list for which there is no matching unique or primary
         key constraint in the referenced table.
  *Action:   Find the correct column names using the ALL_CONS_COLUMNS
         catalog view
  </code></pre>
  
  <p>I'm at a massive loss on where to go from here, I think everythings in order but I just can't point out what's wrong. </p>
  
  <p>Here are the relavent create and alter scripts i'm using if anybody can point out where i'm going wrong:</p>
  
  <p>Creation of Results &amp; DopingTest:</p>
  
  <pre><code>CREATE TABLE Results
  (
  RaceID NUMBER,
  HorseID NUMBER,
  JockeyID NUMBER,
  Position numeric(2)
  );
  
  CREATE TABLE DopingTest
  (
  RaceID NUMBER,
  HorseID NUMBER,
  TakenBy varchar2(60)
  );
  </code></pre>
  
  <p>And the adding of constraints:</p>
  
  <pre><code>ALTER TABLE Results
  ADD(
    CONSTRAINT pk_ResultsID
      PRIMARY KEY (RaceID,HorseID));
  
  ALTER TABLE DopingTest
  ADD(
    CONSTRAINT pk_DopingTest
      PRIMARY KEY (RaceID, HorseID));
  
  ALTER TABLE Results
  ADD(
    CONSTRAINT fk_raceID
      FOREIGN KEY (RaceID)
      REFERENCES Race(RaceID),
    CONSTRAINT fk_horseID
      FOREIGN KEY (HorseID)
      REFERENCES Horse(HorseID),
    CONSTRAINT fk_JockeyID
      FOREIGN KEY (JockeyID)
      REFERENCES Jockey(JockeyID));
  
  ALTER TABLE DopingTest
  ADD(
    CONSTRAINT fk_RaceIDDT
      FOREIGN KEY (RaceID)
      REFERENCES Results(RaceID),
    CONSTRAINT fk_HorseIDDT
      FOREIGN KEY (HorseID)
      REFERENCES Results(HorseID));
  </code></pre>
  
  <p>Any help would be greatly appreciated, thanks. </p>