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_rank" INT,
"winner_age" FLOAT,
"winner_id" INT,
"winner_name" TEXT,
"winner_rank" 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,
"birth_date" DATE,
PRIMARY KEY ("player_id")
);

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





INSERT INTO "players" VALUES ("1", "Emma", "Raducanu", "2002-11-13");
INSERT INTO "players" VALUES ("2", "Leylah", "Fernandez", "2002-09-06");
INSERT INTO "players" VALUES ("3", "Iga", "Swiatek", "2001-05-31");
INSERT INTO "players" VALUES ("4", "Ons", "Jabeur", "1994-08-28");
INSERT INTO "players" VALUES ("5", "Simona", "Halep", "1991-09-27");
INSERT INTO "players" VALUES ("6", "Naomi", "Osaka", "1997-10-16");
INSERT INTO "players" VALUES ("7", "Coco", "Gauff", "2004-03-13");
INSERT INTO "players" VALUES ("8", "Aryna", "Sabalenka", "1998-05-05");
INSERT INTO "players" VALUES ("9", "Garbiñe", "Muguruza", "1993-10-08");
INSERT INTO "players" VALUES ("10", "Petra", "Kvitova", "1990-03-08");
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");
INSERT INTO "matches" VALUES ("5", "12", "19.9", "1", "Emma Raducanu", "8");
INSERT INTO "matches" VALUES ("6", "7", "18.5", "2", "Leylah Fernandez", "15");
INSERT INTO "matches" VALUES ("7", "10", "20.3", "3", "Iga Swiatek", "1");
INSERT INTO "matches" VALUES ("8", "5", "27.8", "4", "Ons Jabeur", "6");
INSERT INTO "matches" VALUES ("9", "3", "29.4", "5", "Simona Halep", "4");
INSERT INTO "matches" VALUES ("10", "2", "24.1", "6", "Naomi Osaka", "9");
INSERT INTO "matches" VALUES ("1", "20", "17.2", "7", "Coco Gauff", "25");
INSERT INTO "matches" VALUES ("2", "8", "23.0", "8", "Aryna Sabalenka", "3");
INSERT INTO "matches" VALUES ("3", "6", "28.7", "9", "Garbiñe Muguruza", "11");
INSERT INTO "matches" VALUES ("4", "4", "31.0", "10", "Petra Kvitova", "5");