title: PostgreSQL: Insert violates foreign key constraint
body: <p>I'm working on a project for which I want to use inheritance (see code below)</p>
  
  <p>When I try to insert something into Profile there is an error.</p>
  
  <pre><code>ERROR:  insert or update on table "profile" violates foreign key 
  constraint "profile_id_fkey"
  DETAIL:  Key (id)=(21) is not present in table "test".
  </code></pre>
  
  <p>I'm using PSequel to inspect the database and the values are visible in the parent. However, I am still able to insert a duplicate primary key in the parent. The insert then works.</p>
  
  <pre><code>CREATE TABLE Test ( 
  ID INTEGER NOT NULL,
  PRIMARY KEY (ID)
  );
  
  CREATE TABLE Testchild (
  PRIMARY KEY (ID) 
  ) INHERITS (Test)
  ;
  
  
  CREATE TABLE Profile (
  ProfileID INTEGER NOT NULL, 
  ID INT NOT NULL, 
  PRIMARY KEY (ProfileID)
  );
  
  ALTER TABLE Profile
  ADD FOREIGN KEY (ID) REFERENCES Test(ID);
  
  INSERT INTO Testchild VALUES (21);
  
  INSERT INTO Profile VALUES (1,21);
  </code></pre>