so I'm having some problems. So basicly I need to import a text file wich contains a task number, firstname and surname and points.
As follows
task 1 Nils Johansson 1
task 1 Maria Johansson 2
task 1 Anna Andersson 0
I need to add all the names into one table with a unique id number for each person. The same name will exist more than once in the text file but can only exist once in the table
I have done like this
CREATE TABLE persons (
id INTEGER PRIMARY KEY AUTOINCREMENT,
firstname TEXT NOT NULL,
surname TEXT NOT NULL,
UNIQUE (firstname, surname) ON CONFLICT IGNORE
Problem 1: I have managed to get all the names into the table but when the program notice a conflict in the names, it ignores it but still increment the id number.
Then i need to add the points, id and task number for each person.
I have done like this.
CREATE TABLE scores (
uppgift INTEGER PRIMARY KEY,
idPerson INTEGER,
score INTEGER,
UNIQUE (uppgift, idPerson) ON CONFLICT IGNORE
Problem 2: I need to collect all the points for each person per task and summarize them.
Thank you in advance and please let me know if you need more information or the entire code I have so far.
Aucun commentaire:
Enregistrer un commentaire