I am making a table called "routes". I want it to be able to contain a list of flights in it. Flight details are shown in the flight tables. I want the “flight” to be an array of foreign keys from the flight table. So, I have this code:
CREATE TABLE routes (
id SERIAL PRIMARY KEY,
flight integer[] ELEMENT REFERENCES flights,
user CHARACTER VARYING(50)
);
But this gives an error:
ERROR: syntax error at or near "ELEMENT"
LINE 2: id SERIAL PRIMARY KEY, flight integer[] ELEMENT REFERENC...
I am using psql (9.3.10)
I used this:
http://blog.2ndquadrant.com/postgresql-9-3-development-array-element-foreign-keys/ as a link, but when I copy this syntax it gives this error.
This is the syntax that I use as a reference:
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
);
source
share