1
Guys, the following is a table called sqlite, and I want the following I don’t want data to repeat, but if someone with a name and surname is registered, I want a person with the same name to be registered but the surname has to be different, or else a different name and the same last name. I’ll give you an example someone with the name
Letícia Almeida
It’s registered at the bank, so I want someone with the name
Letícia Ferreira
Can also be registered, and that someone with the name
Mateus Almeida
Can be registered, I want to be able to register a person even if the name has already been used unless the surname is also not the same, or the same surname more with different name, example of Matthew and the first Leticia, which has different names more equal surnames. Forgive me the quality of the question I’m new here and I’m trying to explain well.
My table:
db.run("CREATE TABLE IF NOT EXISTS Users(
Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
User TEXT, Password TEXT,
Nome TEXT,
Sobrenome TEXT,
UNIQUE(Nome,Sobrenome) ON CONFLICT REPLACE)");
Well, I’m using Node js so db.run and etc, well anyway, at the time I’m going to do the Insert after some Insert it skips some id numbers that is auto incrementable at some point apparently doesn’t have a specific moment.
The "Unique" key guarantees this but in real system this would not be feasible because there are homonyms , could have an index by name but not unique , the id "jumps" because some Inserts may have failed.
– Motta
So ... But I do not want to have to register the same user with the same data that already exists, even because these are where my users' data are, there can be 2 equal logins with the same data in the database, understand?
– user212376
The Unique is correct which is not usual and it for name , in general we use the COF or email for this alternative key , I do not know however the behavior of the ON CONFLICT command.
– Motta
But if I were to use the email to Unique, could I have a person with the same name and last name with a different email address? I don’t know if today’s sites do this, wanted to do it in a beautiful and efficient way. And the on Conflict is a special "command" of the sqlite.
– user212376
Homonyms occur, emails providers nãk allow equals.
– Motta
Okay thanks I’ll use this tip.
– user212376