consider I want to make a multiple step registration form with Javascript(e.g. Angular) and I don't want to do some ajax before all steps are completely done. I've thought may be executing a function in Javascript which take user email as an argument which determine whether email exist in database or not. but actually I don't want my function to do Ajax call. consider each time a user is registered in database this algorithm should be updated.
it's a little hard to say but I mean there should be an algorithm which determines an item exists or not without having items. (I know it seems a little silly. but actually its not).
you get all items from database once and with knowing all items you write an algorithm which determines whether an given item exist in database or not without knowing database items.
consider log in process system can determine whether user password is correct or not without knowing user password . system just knows some thing about user password (hash or md5 or ...)
so we can here execute a function on our existing user table and get some values and strings or ... and with these values we can detect whether user email already exist in database or not without knowing all items.
one of the reasons which I'm asking question is performance issues(consider user table with so many records.) and the second reason is just to be fancy :)
Generate a hash from the email address. Suppose the hash is a 20-bit value (just take the bottom 20 bits of md5 hash, for example). That means you need a 128K byte table where each bit is either 0 or 1 depending on whether there is an email which hashes to that value. You can easily check for an email present by generating the hash and looking it up in the table. A 1 means either the email is used or there is a hash collision. A 0 guarantees the email was not used at the time the table was generated. To reduce the chance of a collision, make sure the number of bits in the table is much larger than the number of users. 20 bits gives 1 million hash buckets.