sorry, i don't speak perl or whatever language that was
but it looks like you are testing for the existence of a row
which to me, no offence, i don't understand why you need to test both columns
some queries, you use the bridge table to qualify the results you want, like an inner join where you know the bridge column is never not going to have a value
other times, you don't care if the row exists or not (e.g. outer join)
in all cases you write the appropriate SQL to do the logic for you
so i don't understand why you think testing the surrogate key is better than testing one of the composite columns
the thing is, you never have to test more than one of the two columns of a composite primary key (which is the way most people design a bridge table), since neither of them can be null, so a missing value indicates an unmatched row and this only happens in an outer join, if you want it to
so i don't see what point you are making
