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_rank_points" INT,
"tourney_name" TEXT,
"winner_id" INT,
"winner_name" TEXT,
"winner_rank_points" INT,
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", "Ashleigh", "Barty", "AUS");
INSERT INTO "players" VALUES ("2", "Simona", "Halep", "ROU");
INSERT INTO "players" VALUES ("3", "Naomi", "Osaka", "JPN");
INSERT INTO "players" VALUES ("4", "Serena", "Williams", "USA");
INSERT INTO "players" VALUES ("5", "Sofia", "Kenin", "USA");
INSERT INTO "players" VALUES ("6", "Petra", "Kvitova", "CZE");
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", "8700");
INSERT INTO "rankings" VALUES ("2", "2", "7000");
INSERT INTO "rankings" VALUES ("3", "3", "6800");
INSERT INTO "rankings" VALUES ("4", "4", "6500");
INSERT INTO "rankings" VALUES ("5", "5", "6200");
INSERT INTO "rankings" VALUES ("6", "6", "6000");
INSERT INTO "rankings" VALUES ("7", "7", "5900");
INSERT INTO "rankings" VALUES ("8", "8", "5800");
INSERT INTO "rankings" VALUES ("9", "9", "5700");
INSERT INTO "rankings" VALUES ("10", "10", "5600");
INSERT INTO "matches" VALUES ("5000", "Australian Open", "1", "Ashleigh Barty", "8700");
INSERT INTO "matches" VALUES ("4800", "Australian Open", "3", "Naomi Osaka", "6800");
INSERT INTO "matches" VALUES ("4700", "Australian Open", "5", "Sofia Kenin", "6200");
INSERT INTO "matches" VALUES ("4600", "Australian Open", "2", "Simona Halep", "7000");
INSERT INTO "matches" VALUES ("4500", "French Open", "4", "Serena Williams", "6500");
INSERT INTO "matches" VALUES ("4400", "Wimbledon", "6", "Petra Kvitova", "6000");
INSERT INTO "matches" VALUES ("4300", "US Open", "7", "Elina Svitolina", "5900");
INSERT INTO "matches" VALUES ("4200", "Australian Open", "8", "Karolina Pliskova", "5800");
INSERT INTO "matches" VALUES ("4100", "Australian Open", "9", "Bianca Andreescu", "5700");
INSERT INTO "matches" VALUES ("4000", "Australian Open", "10", "Garbiñe Muguruza", "5600");