title: Trouble with composite foreign keys in sqlite3
body: <p>there! I have a failing foreign key constraint in sqlite3 and I really have no idea why. I'm using a composite foreign key as discribed here (<a href="http://www.sqlite.org/foreignkeys.html#fk_composite" rel="nofollow">http://www.sqlite.org/foreignkeys.html#fk_composite</a>) and a "normal" foreign key. </p>
  
  <p>Here are my schemas:</p>
  
  <pre><code>sqlite&gt; .schema sources
  CREATE TABLE sources(
      source_id VARCHAR(16) NOT NULL,
      source_type INTEGER NOT NULL,
      title VARCHAR(128) NOT NULL,
      year INTEGER,
      month INTEGER,
      PRIMARY KEY(source_id),
      UNIQUE(title)
  );
  sqlite&gt; .schema author_aliases
  CREATE TABLE author_aliases(
      author_id INTEGER NOT NULL,
      alias_id INTEGER NOT NULL,
      forenames VARCHAR(128),
      surname VARCHAR(128) NOT NULL,
      PRIMARY KEY(author_id, alias_id),
      FOREIGN KEY(author_id) REFERENCES authors(author_id),
      UNIQUE(forenames, surname)
  );
  sqlite&gt; .schema alias_source_relations
  CREATE TABLE alias_source_relations(
      source_id VARCHAR(16) NOT NULL,
      author_id INTEGER NOT NULL,
      alias_id INTEGER NOT NULL,
      PRIMARY KEY(source_id, author_id, alias_id),
      FOREIGN KEY(source_id) REFERENCES sources(source_id),
      FOREIGN KEY(author_id, alias_id) REFERENCES author_aliases(author_id, alias_id)
  );
  </code></pre>
  
  <p>Here is the data the foreign key is referring to:</p>
  
  <pre><code>sqlite&gt; SELECT * FROM sources WHERE source_id='Allen1980';
  Allen1980|0|The definition of electronegativity and the chemistry of the noble gases|1980|
  sqlite&gt; SELECT * FROM author_aliases WHERE author_id=1 and alias_id=1;
  1|1|Leland C.|Allen
  sqlite&gt; SELECT * FROM authors WHERE author_id=1;
  1|Leland Cullen|Allen
  </code></pre>
  
  <p>And here is my insert:</p>
  
  <pre><code>sqlite&gt; INSERT INTO alias_source_relations VALUES(1, 1, 'Allen1980');
  Error: foreign key constraint failed
  </code></pre>
  
  <p>Does anyone know what I am missing? Thanks for your help!</p>
  
  <p>Regards,
  Marian</p>