I have 3 tables (Users, Links and LinkLists) and I want to store user ids and their link ids in an array. However, when I try the code below I get following error:
incompatible types: integer[] and integer
Is there any way that I can store user_id and an array of link ids in a table?
CREATE TABLE Users (
id serial primary key not null,
email varchar(64) unique not null,
);
CREATE TABLE Links (
id serial primary key not null,
name varchar(64) not null
);
CREATE TABLE LinkLists(
user_id integer unique not null REFERENCES Users(id),
links integer [] REFERENCES Links(id) -- problem here --
);
Example:
Users Table*
1 example@gmail.com
Links Table
1 google.com
2 twitter.com
LinkLists Table
1 [1,2]