I just noticed that I accidentally got a duplicate id. My
definitions are here:

CREATE TABLE citations (
    citation_id         INTEGER PRIMARY KEY,
    source_fk           INTEGER REFERENCES sources (source_id)
);

CREATE TABLE relation_citations (
    relation_fk         INTEGER REFERENCES relations (relation_id)
) INHERITS (citations);

ALTER TABLE relation_citations
    ADD CONSTRAINT source_relation_citation UNIQUE 
    (source_fk, relation_fk);
CREATE INDEX cit_relation_key ON relation_citations (relation_fk);

CREATE TABLE event_citations (
    event_fk            INTEGER REFERENCES events (event_id)
) INHERITS (citations);

ALTER TABLE event_citations
    ADD CONSTRAINT source_event_citation UNIQUE 
    (source_fk, event_fk);
CREATE INDEX cit_event_key ON event_citations (event_fk);

And here is the accident:

pgslekt=> insert into relation_citations values (64062,4578,20017);
INSERT 1478990 1
pgslekt=> insert into relation_citations values (64062,4578,20018);
INSERT 1478991 1

I got an error when I transferred the data to my Web database running 
MySQL:

ERROR 1062 at line 19839 in file: 'ss_relation_citations.sql': Duplicate 
entry '64062' for key 1

How can this happen?
-- 
Leif Biberg Kristensen | Registered Linux User #338009
http://solumslekt.org/ | Cruising with Gentoo/KDE

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to