title: SQL: create table with composite referencing primary key, and foreign key
body: <p>So I have the following ER diagram:
  <a href="https://i.stack.imgur.com/vpZ8o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vpZ8o.png" alt="enter image description here"></a></p>
  
  <p>So Subthing is a generalization. Stuff is either made out of Metal or Wood, it can't be just a Subthing. Here's the create code:</p>
  
  <pre><code>CREATE TABLE Thing (
      ThingID INTEGER PRIMARY KEY NOT NULL
  );
  
  CREATE TABLE Subthing (
      consists_of INTEGER REFERENCES Thing(ThingID),
      SubthingID INTEGER NOT NULL,
      PRIMARY KEY (SubthingID, consists_of)
  );
  
  CREATE TABLE Wood (
      Wstuff VARCHAR(40) NOT NULL,
      consists_of INTEGER NOT NULL,
      SubthingID INTEGER NOT NULL,
      FOREIGN KEY (SubthingID, consists_of) REFERENCES Subthing(SubthingID, consists_of),
      PRIMARY KEY (SubthingID, consists_of)
  );
  
  CREATE TABLE Dust (
      DustID INTEGER PRIMARY KEY NOT NULL
  );
  
  CREATE TABLE Metal (
      Mstuff VARCHAR(40) NOT NULL,
      consists_of INTEGER NOT NULL,
      SubthingID INTEGER NOT NULL,
      requires INTEGER NOT NULL REFERENCES Dust(DustID),
      FOREIGN KEY (SubthingID, consists_of) REFERENCES Subthing(SubthingID, consists_of),
      PRIMARY KEY (SubthingID, consists_of)
  );
  </code></pre>
  
  <p>What I want is for Metal to, at the same time, have a primary key which references (SubthingID, consists_of) and a foreign key with requires, referencing DustID. I can't declare it as a foreign key after the fact since (SubthingID, consists_of) is already a foreign key. 
  How could you solve this, other than making requires into a table?</p>