About this question
The example below hows the error: there is no unique constraint matching speicifc keys for the referenced table, and now I cant understand why the error occurs in this case.
BEGIN;
CREATE TABLE foo (
name VARCHAR(256) PRIMARY KEY
);
CREATE TABLE bar(
pkey SERIAL PRIMARY KEY,
foo_fk VARCHAR(256) NOT NULL REFERENCES foo(name),
name VARCHAR(256) NOT NULL,
UNIQUE (foo_fk,name)
);
CREATE TABLE baz(
pkey SERIAL PRIMARY KEY,
bar_fk VARCHAR(256) NOT NULL REFERENCES bar(name),
name VARCHAR(256)
);
COMMIT;
Running the code mentioned above shows the error. Can anybody tell the reason for the error.