I have a table like
create table adjacencies(
relationId int not null primary key auto_increment,
parent int not null,
child int not null,
pathLen int not null
) ;
I'm inserting large amounts of entries like
insert into adjacencies( parent, child, pathLen )
select a, b, c from something where condition ;
So sometimes when I run my insert query, its possible that a (parent,child) relation will already exist and be duplicated. Bad news.
I don't want to create a primary key on ( parent, child ) because that results in a hard fail (query failure).
What I want is a soft fail if there is an attempt to insert a (parent, child) pair that already exists in the table (i.e only that pair gets ignored, and the rest of the query proceeds normally).
What's the best way to do this in MySQL?
(* Wondering why is there a relationId member in this table?)