On 30 Dec 2012, at 7:37pm, Igor Korot <ikoro...@gmail.com> wrote:

> This would've worked if the string will be the same, i.e. "abc def"
> and "abc def".
> However they are not. One is "abc def", another "def abc".
> So from the uniqueness point of view they are different.
> 
> Basically I'm trying to prevent the insertion of:
> 
> "Simon Slavin" and "Slavin Simon"
> 
> into the table which is not make much sense as it's one person.

I missed that.  Sorry.  Three solutions:

A) use application logic to reverse the order of the names and check to see 
that that value doesn't already exist in the table.
B) use a convoluted assembly of ||, substr(X,Y,Z) and instr(X,Y) to swap the 
positions of the words in your TRIGGER test (|| is the concatenation operator)
C) design a custom collating method

I think I favour (A).  The sense of the swapping of words is more about 
real-world interpretation of the information than plain storage of data.

However, your question is missing numerous allowable versions of a name:

Fred Smith
Smith Fred
F Smith
Fred A Smith
Smith, Fred
Smith, F

all of which I consider to be 'the same'.  You also have the problem of 
American names where you can have two people 'Alexander Mason' and 'Mason 
Alexander' who are not the same person.  I'm not sure just dealing with swapped 
names is going to be useful.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to