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" (
"tourney_name" TEXT,
"winner_id" INT,
"winner_name" TEXT,
"winner_rank" INT,
"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_points" INT
);





INSERT INTO "players" VALUES ("1", "Ashleigh", "Barty", "AUS");
INSERT INTO "players" VALUES ("2", "Naomi", "Osaka", "JPN");
INSERT INTO "players" VALUES ("3", "Simona", "Halep", "ROU");
INSERT INTO "players" VALUES ("4", "Serena", "Williams", "USA");
INSERT INTO "players" VALUES ("5", "Victoria", "Azarenka", "BLR");
INSERT INTO "players" VALUES ("6", "Petra", "Kvitova", "CZE");
INSERT INTO "players" VALUES ("7", "Sofia", "Kenin", "USA");
INSERT INTO "players" VALUES ("8", "Elina", "Svitolina", "UKR");
INSERT INTO "matches" VALUES ("Australian Open", "1", "Ashleigh Barty", "1", "7800");
INSERT INTO "matches" VALUES ("Australian Open", "2", "Naomi Osaka", "3", "6150");
INSERT INTO "matches" VALUES ("Australian Open", "3", "Simona Halep", "2", "7000");
INSERT INTO "matches" VALUES ("French Open", "4", "Serena Williams", "5", "3500");
INSERT INTO "matches" VALUES ("Wimbledon", "5", "Victoria Azarenka", "6", "2800");
INSERT INTO "matches" VALUES ("US Open", "6", "Petra Kvitova", "4", "4000");
INSERT INTO "matches" VALUES ("Australian Open", "7", "Sofia Kenin", "10", "1500");
INSERT INTO "matches" VALUES ("Australian Open", "8", "Elina Svitolina", "8", "2200");
INSERT INTO "rankings" VALUES ("7800");
INSERT INTO "rankings" VALUES ("7000");
INSERT INTO "rankings" VALUES ("6150");
INSERT INTO "rankings" VALUES ("4000");
INSERT INTO "rankings" VALUES ("3500");
INSERT INTO "rankings" VALUES ("2800");
INSERT INTO "rankings" VALUES ("2200");
INSERT INTO "rankings" VALUES ("1500");