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_id" INT,
"loser_name" 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" (
"player_id" INT,
FOREIGN KEY ("player_id") REFERENCES "players"("player_id")
);





INSERT INTO "players" VALUES ("1", "Serena", "Williams", "R");
INSERT INTO "players" VALUES ("2", "Venus", "Williams", "R");
INSERT INTO "players" VALUES ("3", "Simona", "Halep", "R");
INSERT INTO "players" VALUES ("4", "Naomi", "Osaka", "R");
INSERT INTO "players" VALUES ("5", "Ashleigh", "Barty", "L");
INSERT INTO "players" VALUES ("6", "Petra", "Kvitova", "L");
INSERT INTO "players" VALUES ("7", "Sofia", "Kenin", "R");
INSERT INTO "players" VALUES ("8", "Bianca", "Andreescu", "R");
INSERT INTO "players" VALUES ("9", "Garbiñe", "Muguruza", "R");
INSERT INTO "players" VALUES ("10", "Elina", "Svitolina", "R");
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");
INSERT INTO "matches" VALUES ("2", "Venus Williams", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("3", "Simona Halep", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("4", "Naomi Osaka", "3", "Simona Halep");
INSERT INTO "matches" VALUES ("5", "Ashleigh Barty", "4", "Naomi Osaka");
INSERT INTO "matches" VALUES ("6", "Petra Kvitova", "5", "Ashleigh Barty");
INSERT INTO "matches" VALUES ("7", "Sofia Kenin", "6", "Petra Kvitova");
INSERT INTO "matches" VALUES ("8", "Bianca Andreescu", "7", "Sofia Kenin");
INSERT INTO "matches" VALUES ("9", "Garbiñe Muguruza", "8", "Bianca Andreescu");
INSERT INTO "matches" VALUES ("10", "Elina Svitolina", "9", "Garbiñe Muguruza");
INSERT INTO "matches" VALUES ("2", "Venus Williams", "10", "Elina Svitolina");
INSERT INTO "matches" VALUES ("3", "Simona Halep", "2", "Venus Williams");
INSERT INTO "matches" VALUES ("5", "Ashleigh Barty", "3", "Simona Halep");
INSERT INTO "matches" VALUES ("7", "Sofia Kenin", "5", "Ashleigh Barty");
INSERT INTO "matches" VALUES ("9", "Garbiñe Muguruza", "7", "Sofia Kenin");
INSERT INTO "matches" VALUES ("2", "Venus Williams", "9", "Garbiñe Muguruza");