Hi,

PostgreSQL doesn't allow the creation of a foreign key to a combination
of fields that has got no dedicated unique key but is unique nonetheless
because a subset of the combination of fields has a unique constraint.
Example:

CREATE TABLE p (
    name TEXT PRIMARY KEY,
    "type" TEXT
);
                                                                                
CREATE TABLE f (
    name TEXT,
    "type" TEXT,
    FOREIGN KEY(name, "type") REFERENCES p(name, "type")
);
ERROR:  there is no unique constraint matching given keys for referenced table "p"

Is this on purpose? I think the foreign key should be allowed. Creating
an extra unique key only has a negative impact on performance, right?

Thanks

-- 
Markus Bertheau <[EMAIL PROTECTED]>


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to