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,
"winner_rank_points" INT,
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,
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");
INSERT INTO "players" VALUES ("2", "Maria", "Sharapova");
INSERT INTO "players" VALUES ("3", "Simona", "Halep");
INSERT INTO "players" VALUES ("4", "Naomi", "Osaka");
INSERT INTO "players" VALUES ("5", "Ashleigh", "Barty");
INSERT INTO "players" VALUES ("6", "Petra", "Kvitova");
INSERT INTO "players" VALUES ("7", "Angelique", "Kerber");
INSERT INTO "players" VALUES ("8", "Elina", "Svitolina");
INSERT INTO "players" VALUES ("9", "Karolina", "Pliskova");
INSERT INTO "players" VALUES ("10", "Bianca", "Andreescu");
INSERT INTO "matches" VALUES ("2", "Maria Sharapova", "1", "Serena Williams", "8000");
INSERT INTO "matches" VALUES ("3", "Simona Halep", "1", "Serena Williams", "8000");
INSERT INTO "matches" VALUES ("4", "Naomi Osaka", "1", "Serena Williams", "8000");
INSERT INTO "matches" VALUES ("5", "Ashleigh Barty", "1", "Serena Williams", "8000");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "2", "Maria Sharapova", "6500");
INSERT INTO "matches" VALUES ("3", "Simona Halep", "2", "Maria Sharapova", "6500");
INSERT INTO "matches" VALUES ("4", "Naomi Osaka", "3", "Simona Halep", "7200");
INSERT INTO "matches" VALUES ("5", "Ashleigh Barty", "3", "Simona Halep", "7200");
INSERT INTO "matches" VALUES ("6", "Petra Kvitova", "4", "Naomi Osaka", "7000");
INSERT INTO "matches" VALUES ("7", "Angelique Kerber", "5", "Ashleigh Barty", "7500");
INSERT INTO "matches" VALUES ("8", "Elina Svitolina", "6", "Petra Kvitova", "6000");
INSERT INTO "matches" VALUES ("9", "Karolina Pliskova", "7", "Angelique Kerber", "5800");
INSERT INTO "matches" VALUES ("10", "Bianca Andreescu", "8", "Elina Svitolina", "5500");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "9", "Karolina Pliskova", "5200");
INSERT INTO "matches" VALUES ("2", "Maria Sharapova", "10", "Bianca Andreescu", "5000");
INSERT INTO "matches" VALUES ("6", "Petra Kvitova", "1", "Serena Williams", "8000");
INSERT INTO "matches" VALUES ("7", "Angelique Kerber", "1", "Serena Williams", "8000");
INSERT INTO "matches" VALUES ("8", "Elina Svitolina", "1", "Serena Williams", "8000");
INSERT INTO "matches" VALUES ("9", "Karolina Pliskova", "1", "Serena Williams", "8000");
INSERT INTO "matches" VALUES ("10", "Bianca Andreescu", "1", "Serena Williams", "8000");
INSERT INTO "rankings" VALUES ("1", "1", "8000");
INSERT INTO "rankings" VALUES ("2", "3", "7200");
INSERT INTO "rankings" VALUES ("3", "4", "7000");
INSERT INTO "rankings" VALUES ("4", "5", "7500");
INSERT INTO "rankings" VALUES ("5", "2", "6500");
INSERT INTO "rankings" VALUES ("6", "6", "6000");
INSERT INTO "rankings" VALUES ("7", "7", "5800");
INSERT INTO "rankings" VALUES ("8", "8", "5500");
INSERT INTO "rankings" VALUES ("9", "9", "5200");
INSERT INTO "rankings" VALUES ("10", "10", "5000");