I
I
Ivan2014-09-06 11:50:20
PHP
Ivan, 2014-09-06 11:50:20

Is it worth it to check for duplicates when adding a record with a unique hash to the database?

Let's take an example.
In one unnamed database table, there is a hash field containing a unique set of characters automatically generated for each record before it is added to the database. Should I check for records with the same hash before adding a record? If yes, how? a while loop? Is this 0.0000000000001% chance worth it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vdem, 2014-09-06
@0neS

If at all this situation (coincidence) is handled, then it is better to make this field a unique constraint, and if an error occurs when adding a record, try another hash.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question