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,
"tourney_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
);





INSERT INTO "players" VALUES ("1", "Serena", "Williams");
INSERT INTO "players" VALUES ("2", "Naomi", "Osaka");
INSERT INTO "players" VALUES ("3", "Ashleigh", "Barty");
INSERT INTO "players" VALUES ("4", "Simona", "Halep");
INSERT INTO "players" VALUES ("5", "Sofia", "Kenin");
INSERT INTO "players" VALUES ("6", "Victoria", "Azarenka");
INSERT INTO "players" VALUES ("7", "Angelique", "Kerber");
INSERT INTO "players" VALUES ("8", "Petra", "Kvitova");
INSERT INTO "players" VALUES ("9", "Garbine", "Muguruza");
INSERT INTO "players" VALUES ("10", "Aryna", "Sabalenka");
INSERT INTO "matches" VALUES ("4", "Simona Halep", "Australian Open", "1", "Serena Williams", "9000");
INSERT INTO "matches" VALUES ("3", "Ashleigh Barty", "Wimbledon", "2", "Naomi Osaka", "8500");
INSERT INTO "matches" VALUES ("5", "Sofia Kenin", "Australian Open", "3", "Ashleigh Barty", "9200");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "French Open", "4", "Simona Halep", "8800");
INSERT INTO "matches" VALUES ("6", "Victoria Azarenka", "US Open", "5", "Sofia Kenin", "7500");
INSERT INTO "matches" VALUES ("7", "Angelique Kerber", "Australian Open", "6", "Victoria Azarenka", "7800");
INSERT INTO "matches" VALUES ("8", "Petra Kvitova", "Wimbledon", "7", "Angelique Kerber", "8100");
INSERT INTO "matches" VALUES ("9", "Garbine Muguruza", "Australian Open", "8", "Petra Kvitova", "8900");
INSERT INTO "matches" VALUES ("10", "Aryna Sabalenka", "French Open", "9", "Garbine Muguruza", "7200");
INSERT INTO "matches" VALUES ("2", "Naomi Osaka", "US Open", "10", "Aryna Sabalenka", "7000");
INSERT INTO "matches" VALUES ("5", "Sofia Kenin", "Australian Open", "1", "Serena Williams", "9100");
INSERT INTO "matches" VALUES ("8", "Petra Kvitova", "Australian Open", "3", "Ashleigh Barty", "9300");
INSERT INTO "matches" VALUES ("6", "Victoria Azarenka", "Australian Open", "9", "Garbine Muguruza", "8950");
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");