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,
"loser_name" TEXT,
"match_num" INT,
"tourney_name" TEXT,
"winner_hand" TEXT,
"winner_id" INT,
"winner_name" TEXT,
FOREIGN KEY ("loser_id") REFERENCES "players"("player_id"),
FOREIGN KEY ("winner_id") REFERENCES "players"("player_id")
);

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

CREATE TABLE "rankings" (
"ranking" INT
);





INSERT INTO "players" VALUES ("1", "Serena", "Williams", "R");
INSERT INTO "players" VALUES ("2", "Maria", "Sharapova", "R");
INSERT INTO "players" VALUES ("3", "Petra", "Kvitova", "L");
INSERT INTO "players" VALUES ("4", "Simona", "Halep", "R");
INSERT INTO "players" VALUES ("5", "Angelique", "Kerber", "L");
INSERT INTO "players" VALUES ("6", "Caroline", "Wozniacki", "R");
INSERT INTO "players" VALUES ("7", "Victoria", "Azarenka", "R");
INSERT INTO "players" VALUES ("8", "Garbine", "Muguruza", "R");
INSERT INTO "players" VALUES ("9", "Naomi", "Osaka", "R");
INSERT INTO "players" VALUES ("10", "Ashleigh", "Barty", "R");
INSERT INTO "players" VALUES ("11", "Bianca", "Andreescu", "R");
INSERT INTO "players" VALUES ("12", "Sloane", "Stephens", "R");
INSERT INTO "players" VALUES ("13", "Madison", "Keys", "R");
INSERT INTO "players" VALUES ("14", "Elina", "Svitolina", "R");
INSERT INTO "players" VALUES ("15", "Karolina", "Pliskova", "R");
INSERT INTO "players" VALUES ("16", "Aryna", "Sabalenka", "R");
INSERT INTO "players" VALUES ("17", "Johanna", "Konta", "R");
INSERT INTO "players" VALUES ("18", "Belinda", "Bencic", "R");
INSERT INTO "players" VALUES ("19", "Kiki", "Bertens", "R");
INSERT INTO "players" VALUES ("20", "Sofia", "Kenin", "R");
INSERT INTO "matches" VALUES ("R", "2", "Maria Sharapova", "1", "WTA Championships", "R", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("R", "4", "Simona Halep", "2", "WTA Championships", "L", "3", "Petra Kvitova");
INSERT INTO "matches" VALUES ("R", "6", "Caroline Wozniacki", "3", "WTA Championships", "L", "5", "Angelique Kerber");
INSERT INTO "matches" VALUES ("R", "8", "Garbine Muguruza", "4", "WTA Championships", "R", "7", "Victoria Azarenka");
INSERT INTO "matches" VALUES ("R", "10", "Ashleigh Barty", "5", "WTA Championships", "R", "9", "Naomi Osaka");
INSERT INTO "matches" VALUES ("R", "12", "Sloane Stephens", "6", "WTA Championships", "R", "11", "Bianca Andreescu");
INSERT INTO "matches" VALUES ("R", "14", "Elina Svitolina", "7", "WTA Championships", "R", "13", "Madison Keys");
INSERT INTO "matches" VALUES ("R", "16", "Aryna Sabalenka", "8", "WTA Championships", "R", "15", "Karolina Pliskova");
INSERT INTO "matches" VALUES ("R", "18", "Belinda Bencic", "9", "WTA Championships", "R", "17", "Johanna Konta");
INSERT INTO "matches" VALUES ("R", "20", "Sofia Kenin", "10", "WTA Championships", "R", "19", "Kiki Bertens");
INSERT INTO "matches" VALUES ("R", "1", "Serena Williams", "11", "WTA Championships", "L", "3", "Petra Kvitova");
INSERT INTO "matches" VALUES ("L", "3", "Petra Kvitova", "12", "WTA Championships", "R", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("R", "5", "Angelique Kerber", "13", "Other Tournament", "R", "2", "Maria Sharapova");
INSERT INTO "matches" VALUES ("R", "7", "Victoria Azarenka", "14", "WTA Championships", "L", "5", "Angelique Kerber");
INSERT INTO "matches" VALUES ("R", "9", "Naomi Osaka", "15", "WTA Championships", "L", "3", "Petra Kvitova");
INSERT INTO "matches" VALUES ("R", "11", "Bianca Andreescu", "16", "WTA Championships", "L", "5", "Angelique Kerber");
INSERT INTO "matches" VALUES ("R", "13", "Madison Keys", "17", "WTA Championships", "L", "3", "Petra Kvitova");
INSERT INTO "matches" VALUES ("R", "15", "Karolina Pliskova", "18", "WTA Championships", "L", "5", "Angelique Kerber");
INSERT INTO "matches" VALUES ("R", "17", "Johanna Konta", "19", "WTA Championships", "L", "3", "Petra Kvitova");
INSERT INTO "matches" VALUES ("R", "19", "Kiki Bertens", "20", "WTA Championships", "L", "5", "Angelique Kerber");
INSERT INTO "matches" VALUES ("R", "1", "Serena Williams", "21", "WTA Championships", "L", "5", "Angelique Kerber");
INSERT INTO "matches" VALUES ("L", "3", "Petra Kvitova", "22", "Other Tournament", "R", "1", "Serena Williams");
INSERT INTO "rankings" VALUES ("1");
INSERT INTO "rankings" VALUES ("2");
INSERT INTO "rankings" VALUES ("3");
INSERT INTO "rankings" VALUES ("4");
INSERT INTO "rankings" VALUES ("5");
INSERT INTO "rankings" VALUES ("6");
INSERT INTO "rankings" VALUES ("7");
INSERT INTO "rankings" VALUES ("8");
INSERT INTO "rankings" VALUES ("9");
INSERT INTO "rankings" VALUES ("10");