title: Why do I get 'DBD::SQLite::db do failed: near "transaction": syntax error' when I try to create a SQLite table with a foreign key constraint?
body: <p>I'm trying to create a database with two tables: customer and transaction (one customer can do many transactions, one transaction can only be done by one customer). I'm using the following Perl code:</p>
  
  <pre><code>my $dbh = DBI-&gt;connect("dbi:SQLite:dbname=$RealBin/active.db","","")
      or die $DBI::errstr;
  
  my @ddl = (
      "CREATE TABLE IF NOT EXISTS customer (
        id INTEGER PRIMARY KEY UNIQUE,
        id_1 INTEGER,
        id_2 INTEGER,
        name TEXT
      )",
      "CREATE TABLE IF NOT EXISTS transaction (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        customer_id INTEGER REFERENCES customer(id),
      )"
  );
  
  for my $sql (@ddl){
    $dbh-&gt;do($sql);
  }
  </code></pre>
  
  <p>When I run my script, I'm getting the following error:</p>
  
  <pre><code>DBD::SQLite::db do failed: near "transaction": syntax error at
      t/oneToMany.t line 28 (#1)
  DBD::SQLite::db do failed: near "transaction": syntax error at t/oneToMany.t line 28.
  DBD::SQLite::db do failed: near "transaction": syntax error at
      t/oneToMany.t line 38 (#1)
  </code></pre>
  
  <p>The line number 28 is this one:</p>
  
  <pre><code>$dbh-&gt;do($sql);
  </code></pre>
  
  <p>Can you please tell me what I'm doing wrong?</p>