Of course if you do use a separate query to guarantee uniqueness then
you need a transaction that is spanning the queries. Otherwise in a
pseudo-race condition this will not ensure uniqueness. E.g.,
a) check name "foo" is unique --> result = true
b) insert record with name "foo"
a) insert record with name "foo" --> fails! |