I think this is a pretty common problem.
I\'ve got a table user(id INT ...) and a table photo(id BIGINT, owner INT). owner is a reference o
user(id INT ...)
photo(id BIGINT, owner INT)
A better alternative would be to check the number of rows when you do the insert:
insert into photos(id,owner) select 1,2 from dual where (select count(*) from photos where id=1) < 10