title: sqlite3 "foreign key constraint failed"
body: <p>I've set up two tables:</p>
  
  <pre><code>CREATE TABLE A
  (
      id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
      name TEXT
   );
  
  CREATE TABLE B
  (
      id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
      id2 INTEGER,
      book TEXT,
      FOREIGN KEY(id2) REFERENCES A(id)
  );
  </code></pre>
  
  <p>After I insert data into <code>A</code>, it looks like this:</p>
  
  <pre><code>1    John
  
  2    Amy
  
  3    Peter
  </code></pre>
  
  <p>After I insert data into <code>B</code>, it looks like this:</p>
  
  <pre><code>1     1     Lord of the Rings
  
  2     1     Catch 22
  
  3     2     Sum of All Fears
  
  4     3     Hunt for Red October
  </code></pre>
  
  <p>I then execute the following statement:</p>
  
  <pre><code>delete from a where id=1;
  </code></pre>
  
  <p>I get the following: <code>"Error: foreign key constraint failed"</code></p>
  
  <p>I then restart <code>sqlite3</code> and try again but this time I enter this first:</p>
  
  <pre><code>PRAGMA foreign_keys = 1;
  </code></pre>
  
  <p>it still doesn't work......</p>