i m having this error:
ERROR: there is no unique constraint matching given keys for referenced table "vulling"
This is my code to make a foreign key:
ALTER TABLE put_25_vlak_1_spoor
ADD FOREIGN KEY (spoor,vulling)
REFERENCES vulling(spoor,vulling);
The tables are made this way:
CREATE TABLE put_25_vlak_1_spoor
(
id serial NOT NULL,
geometry_spoor geometry(MultiPolygon,28992),
spoor integer NOT NULL,
put integer,
vlak integer,
vulling integer NOT NULL,
CONSTRAINT put_25_vlak_1_spoor_pkey PRIMARY KEY (spoor, vulling)
)
CREATE TABLE vulling
(
vlak smallint,
textuur character varying(8),
vulling integer NOT NULL,
spoor integer NOT NULL,
put integer NOT NULL,
CONSTRAINT vulling_pkey PRIMARY KEY (vulling, put, spoor)
)
I read this threads on stackoverflow but i don't fully understand what they are saying:
PostgreSQL constraint problems
What is causing ERROR: there is no unique constraint matching given keys for referenced table?
I hope somebody can help me out. Im very new to postgres and dont fully understand how the foreign keys work.
Cheers