title: Postgres creating a Table with an array of foreign keys
body: <p>I am making a table named "routes". I want it to be able to contain a list of flights in it. The flights' details are in the flights tables. I want "flight" to be an array of foreign key ids from the flights table. So, I have this code:</p>
  
  <pre><code>CREATE TABLE routes (
  id SERIAL PRIMARY KEY,
  flight integer[] ELEMENT REFERENCES flights,
  user CHARACTER VARYING(50)
  );
  </code></pre>
  
  <p>But, it gives the error:</p>
  
  <pre><code>ERROR:  syntax error at or near "ELEMENT"
  LINE 2:     id SERIAL PRIMARY KEY, flight integer[] ELEMENT REFERENC...
  </code></pre>
  
  <p>I am using psql (9.3.10)</p>
  
  <p>I have used this:
  <a href="http://blog.2ndquadrant.com/postgresql-9-3-development-array-element-foreign-keys/" rel="noreferrer">http://blog.2ndquadrant.com/postgresql-9-3-development-array-element-foreign-keys/</a> as a reference, but when I copy that syntax it gives this error.</p>
  
  <p>This is the syntax that I am using as a reference:</p>
  
  <pre><code>CREATE TABLE races (
     race_id integer PRIMARY KEY,
     title text,
     race_day DATE,
     ...
     practice1_positions integer[] ELEMENT REFERENCES drivers,
     practice2_positions integer[] ELEMENT REFERENCES drivers,
     practice3_positions integer[] ELEMENT REFERENCES drivers,
     qualifying_positions integer[] ELEMENT REFERENCES drivers,
     final_positions integer[] ELEMENT REFERENCES drivers
  );
  </code></pre>