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,
"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,
"country_code" TEXT,
PRIMARY KEY ("player_id")
);

CREATE TABLE "rankings" (
"ranking" INT,
"player_id" INT,
"ranking_points" INT,
FOREIGN KEY ("player_id") REFERENCES "players"("player_id")
);





INSERT INTO "players" VALUES ("1", "Serena", "Williams", "USA");
INSERT INTO "players" VALUES ("2", "Simona", "Halep", "ROU");
INSERT INTO "players" VALUES ("3", "Naomi", "Osaka", "JPN");
INSERT INTO "players" VALUES ("4", "Ashleigh", "Barty", "AUS");
INSERT INTO "players" VALUES ("5", "Petra", "Kvitova", "CZE");
INSERT INTO "players" VALUES ("6", "Sofia", "Kenin", "USA");
INSERT INTO "players" VALUES ("7", "Elina", "Svitolina", "UKR");
INSERT INTO "players" VALUES ("8", "Karolina", "Pliskova", "CZE");
INSERT INTO "players" VALUES ("9", "Bianca", "Andreescu", "CAN");
INSERT INTO "players" VALUES ("10", "Garbiñe", "Muguruza", "ESP");
INSERT INTO "rankings" VALUES ("1", "1", "8500");
INSERT INTO "rankings" VALUES ("2", "2", "7800");
INSERT INTO "rankings" VALUES ("3", "3", "7200");
INSERT INTO "rankings" VALUES ("4", "4", "6900");
INSERT INTO "rankings" VALUES ("5", "5", "6500");
INSERT INTO "rankings" VALUES ("6", "6", "6000");
INSERT INTO "rankings" VALUES ("7", "7", "5800");
INSERT INTO "rankings" VALUES ("8", "8", "5600");
INSERT INTO "rankings" VALUES ("9", "9", "5400");
INSERT INTO "rankings" VALUES ("10", "10", "5200");
INSERT INTO "matches" VALUES ("2", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("3", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("4", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("5", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("6", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("7", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("8", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("9", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("10", "1", "Serena Williams");
INSERT INTO "matches" VALUES ("3", "2", "Simona Halep");
INSERT INTO "matches" VALUES ("4", "2", "Simona Halep");
INSERT INTO "matches" VALUES ("5", "2", "Simona Halep");
INSERT INTO "matches" VALUES ("6", "3", "Naomi Osaka");
INSERT INTO "matches" VALUES ("7", "3", "Naomi Osaka");
INSERT INTO "matches" VALUES ("8", "4", "Ashleigh Barty");
INSERT INTO "matches" VALUES ("9", "5", "Petra Kvitova");
INSERT INTO "matches" VALUES ("10", "6", "Sofia Kenin");
INSERT INTO "matches" VALUES ("1", "7", "Elina Svitolina");
INSERT INTO "matches" VALUES ("2", "8", "Karolina Pliskova");
INSERT INTO "matches" VALUES ("3", "9", "Bianca Andreescu");
INSERT INTO "matches" VALUES ("4", "10", "Garbiñe Muguruza");