Thomas, another problem with the hash solution is that it doesn't deal with weird things like spacing or casing. Also - Ave/avenue, Street, st., st, and so forth. If you're the same Thomas I think you are, also remember how many ways someone can write "Jalan".
Hashing is a really good solution for EXACT duplicates, which mostly prevents a person from hitting submit twice in a row. If you're trying to prevent two people from submitting the same address, it might be pretty tough. There probably is a better, more computer science-y solution for finding things that are pretty close ( http://en.wikipedia.org/wiki/Approximate_string_matching), but the better the user experience, the more expensive it'll be to do well. Another way could be to use client side geocoding and determine a lat,long, then just using that plus some fuzzy string matching to identify similar addresses (near each other). -- Ikai Lan Developer Programs Engineer, Google App Engine plus.ikailan.com | twitter.com/ikai On Wed, Sep 7, 2011 at 6:50 AM, Robert Kluin <[email protected]> wrote: > You're right about changing filed values, but the problem with a > separate field is that it takes much more work to do it > transactionally. With a column + queries, you will have a race > condition without adding additional logic (using another entity with > the hash as the key-name). > > > Robert > > > > On Wed, Sep 7, 2011 at 02:27, Waleed Abdulla <[email protected]> wrote: > > Works, unless you want to allow users to edit their entries. If a user > > changes the address after submitting then the new key is now different > and > > you'll end up saving a second entity. I wouldn't use any user editable > data > > in the key. Instead, I'd add a separate column to include your hash. > > > > > > On Tue, Sep 6, 2011 at 11:32 PM, Robert Kluin <[email protected]> > > wrote: > >> > >> Hi Thomas, > >> If you want to avoid duplicates, the hash solution is great. > >> Generate the hash, then In a transaction try to fetch the entity by > >> id. If you can't get it, insert it. > >> > >> > >> Robert > >> > >> > >> > >> > >> > >> > >> On Tue, Sep 6, 2011 at 21:16, Thomas Wiradikusuma > >> <[email protected]> wrote: > >> > Hi guys, > >> > > >> > I'm working on something like AirBnB but much simpler. I want to hint > >> > user whenever he/she tries to submit duplicate entry. > >> > > >> > Currently, my model looks like: > >> > > >> > House { > >> > Id > >> > Username > >> > Address > >> > State > >> > Country > >> > } > >> > > >> > The id is made of address+state+country MD5. Is this the "correct" way > >> > to do it? Or, should I go with auto-generated Id and add extra field > >> > named 'hash', or how? > >> > > >> > > >> > > >> > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups "Google App Engine" group. > >> > To post to this group, send email to > [email protected]. > >> > To unsubscribe from this group, send email to > >> > [email protected]. > >> > For more options, visit this group at > >> > http://groups.google.com/group/google-appengine?hl=en. > >> > > >> > > >> > >> -- > >> You received this message because you are subscribed to the Google > Groups > >> "Google App Engine" group. > >> To post to this group, send email to [email protected]. > >> To unsubscribe from this group, send email to > >> [email protected]. > >> For more options, visit this group at > >> http://groups.google.com/group/google-appengine?hl=en. > >> > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google App Engine" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > > http://groups.google.com/group/google-appengine?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
