I'm not familiar enough with ANSI SQL standards to know if this is possible in MySQL, but you could implement a trigger that fails if you try to insert a duplicate row. Merely checking to see if the row exists first, and then inserting it if it doesn't isn't good enough, because a race condition exists. Say that your program checks to see if the row exists and finds that it doesn't. Now, some other application inserts the row. Now, your application inserts it. Bad mojo. Better to use the trigger to check for exitance on insertion.