title: Adding foreign key constraint to associative entity
body: <p>I have 3 tables:<br><br>
  1) SERVICE_REQUESTS (Parent)</p>
  
  <pre><code>CREATE TABLE SERVICE_REQUESTS(
  service_id           NUMBER (7)    NOT NULL,
  serial_number        NUMBER (10)   NOT NULL,
  service_date         DATE          NOT NULL,
  service_description  VARCHAR(50)   NOT NULL,
  hourly_rate          NUMBER(5,2)   NOT NULL,
  customer_id          NUMBER  (5)   NOT NULL,
  employee_id          NUMBER  (3)   NOT NULL,
  
  CONSTRAINT service_request_pk PRIMARY KEY(service_id, serial_number));
  </code></pre>
  
  <p><br>
  2) SERVICE_PARTS (Associative Entity to solve M:M relationship)</p>
  
  <pre><code>CREATE TABLE SERVICE_PARTS(
  service_id           NUMBER  (7)   NOT NULL,
  part_id              NUMBER (10)   NOT NULL,
  quantity             NUMBER  (4)   NOT NULL,
  unit_cost            NUMBER(7,2)   NOT NULL,
  
  CONSTRAINT service_part_pk PRIMARY KEY(service_id, part_id));
  </code></pre>
  
  <p><br>
  3) PARTS (Parent)</p>
  
  <pre><code>CREATE TABLE PARTS(
  part_id              NUMBER (10)   NOT NULL,
  part_description     VARCHAR(50)   NOT NULL,
  cost                  NUMBER(7,2)   NOT NULL,
  quantity_on_hand     NUMBER  (5)   NOT NULL,
  
  CONSTRAINT part_pk PRIMARY KEY(part_id));
  </code></pre>
  
  <p><br>
  I've created a foreign key constraint from <code>SERVICE_PARTS</code> to <code>PARTS</code> with the following statement:</p>
  
  <pre><code>ALTER TABLE service_parts
    ADD CONSTRAINT service_parts_part_id_fk
      FOREIGN KEY (part_id)
        REFERENCES parts(part_id);
  </code></pre>
  
  <p>Now I'm trying to create a foreign key constraint from <code>SERVICE_PARTS</code> to <code>SERVICE_REQUESTS</code> using the follow statement:</p>
  
  <pre><code>ALTER TABLE service_parts
    ADD CONSTRAINT service_parts_service_id_fk
      FOREIGN KEY (service_id)
        REFERENCES service_requests(service_id);
  </code></pre>
  
  <p>But I get the following error: <code>ORA-02270: no matching unique or primary key for this column-list</code>. Why does it allow a constraint to be added for the part_id but not the service_id?</p>
  
  <p>I've attached my ER Diagram for visual clarification:
  <img src="https://i.stack.imgur.com/Mztlf.png" alt="enter image description here"></p>