Search Postgresql Archives

Referencing "less-unique" foreign keys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

We migrated a database from version 7.3 something to 7.4.7 a while ago, and ever since that time we can't make new foreign keys to a particular table. The problem is that the primary key on that table is on two columns that are unique together, but that only one of them should be referenced from the other table.

Tables are as follows:

CREATE TABLE localization (
	localization_id		text	NOT NULL,
	language_id		integer	NOT NULL REFERENCES language(language_id) MATCH FULL,
	content			text	NOT NULL
	PRIMARY KEY (localization_id, language_id)
);

CREATE TABLE description (
	description_id		serial	PRIMARY KEY,
	content			text	NOT NULL REFERENCES localization(localization_id)
);

I'm not sure how we got the "content" column from "description" to reference "localization" back in version 7.3. Fact is, we can't seem to do this anymore since version 7.4:

psql> ALTER TABLE description ADD CONSTRAINT fk_description_content FOREIGN KEY (content) REFERENCES localization(localization_id); ERROR: there is no unique constraint matching given keys for referenced table "localization"

Any way around this?

--
Alban Hertroys
alban@xxxxxxxxxxxxxxxxx

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

//Showing your Vision to the World//

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux