PRAGMA foreign_keys = ON;

PRAGMA writable_schema = 1;
DELETE FROM sqlite_master WHERE type IN ("table", "index", "trigger");
PRAGMA writable_schema = 0;
VACUUM;

CREATE TABLE "matches" (
"loser_hand" TEXT,
"loser_id" INT,
"tourney_id" TEXT,
"tourney_name" TEXT,
"winner_hand" TEXT,
"winner_id" INT,
FOREIGN KEY ("loser_id") REFERENCES "players"("player_id"),
FOREIGN KEY ("winner_id") REFERENCES "players"("player_id")
);

CREATE TABLE "players" (
"player_id" INT UNIQUE,
"hand" TEXT,
PRIMARY KEY ("player_id")
);





INSERT INTO "players" VALUES ("1", "L");
INSERT INTO "players" VALUES ("2", "R");
INSERT INTO "players" VALUES ("3", "L");
INSERT INTO "players" VALUES ("4", "R");
INSERT INTO "players" VALUES ("5", "L");
INSERT INTO "players" VALUES ("6", "R");
INSERT INTO "players" VALUES ("7", "L");
INSERT INTO "players" VALUES ("8", "R");
INSERT INTO "players" VALUES ("9", "L");
INSERT INTO "players" VALUES ("10", "R");
INSERT INTO "matches" VALUES ("R", "2", "T1", "WTA Championships", "L", "1");
INSERT INTO "matches" VALUES ("L", "3", "T2", "Other Tournament", "R", "4");
INSERT INTO "matches" VALUES ("R", "4", "T3", "WTA Championships", "L", "3");
INSERT INTO "matches" VALUES ("L", "5", "T4", "WTA Championships", "R", "2");
INSERT INTO "matches" VALUES ("R", "6", "T5", "Other Tournament", "L", "5");
INSERT INTO "matches" VALUES ("L", "7", "T6", "WTA Championships", "L", "1");
INSERT INTO "matches" VALUES ("R", "8", "T7", "WTA Championships", "L", "7");
INSERT INTO "matches" VALUES ("L", "9", "T8", "Other Tournament", "R", "10");
INSERT INTO "matches" VALUES ("R", "10", "T9", "WTA Championships", "L", "9");
INSERT INTO "matches" VALUES ("L", "1", "T10", "WTA Championships", "R", "2");