in reply to
Generate a unique ID
I have databases with over 750k entries using UUID for each row and have never ran into a collision -- over a 2 year period. Are you storing this unique ID somewhere? Otherwise why would the same ID matter? If you are storing this ID, then you may be able to just check a newly generated UUID against your database and generate a new one if collision does occur. But you will find that part of your code will be practically dead code anyway because it will not find any collision. So don't bother. Just use UUID, go on to implement something cool first. And if UUIDs are colliding because your program is so popular it is being used millions times per second, then come back to solve this problem.