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,
"winner_id" 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" (
"ranking_date" DATE
);





INSERT INTO "players" VALUES ("1", "Serena", "Williams", "1981-09-26");
INSERT INTO "players" VALUES ("2", "Venus", "Williams", "1980-06-17");
INSERT INTO "players" VALUES ("3", "Maria", "Sharapova", "1987-04-19");
INSERT INTO "players" VALUES ("4", "Simona", "Halep", "1991-09-27");
INSERT INTO "players" VALUES ("5", "Naomi", "Osaka", "1997-10-16");
INSERT INTO "players" VALUES ("6", "Ashleigh", "Barty", "1996-04-24");
INSERT INTO "players" VALUES ("7", "Iga", "Swiatek", "2001-05-31");
INSERT INTO "players" VALUES ("8", "Coco", "Gauff", "2004-03-13");
INSERT INTO "players" VALUES ("9", "Emma", "Raducanu", "2002-11-13");
INSERT INTO "players" VALUES ("10", "Aryna", "Sabalenka", "1998-05-05");
INSERT INTO "matches" VALUES ("2", "1");
INSERT INTO "matches" VALUES ("3", "1");
INSERT INTO "matches" VALUES ("4", "3");
INSERT INTO "matches" VALUES ("5", "4");
INSERT INTO "matches" VALUES ("6", "5");
INSERT INTO "matches" VALUES ("7", "6");
INSERT INTO "matches" VALUES ("8", "7");
INSERT INTO "matches" VALUES ("9", "8");
INSERT INTO "matches" VALUES ("10", "9");
INSERT INTO "matches" VALUES ("1", "10");
INSERT INTO "matches" VALUES ("2", "4");
INSERT INTO "matches" VALUES ("3", "5");
INSERT INTO "matches" VALUES ("4", "6");
INSERT INTO "matches" VALUES ("5", "7");
INSERT INTO "matches" VALUES ("6", "8");
INSERT INTO "rankings" VALUES ("2023-01-01");
INSERT INTO "rankings" VALUES ("2023-01-08");
INSERT INTO "rankings" VALUES ("2023-01-15");
INSERT INTO "rankings" VALUES ("2023-01-22");
INSERT INTO "rankings" VALUES ("2023-01-29");
INSERT INTO "rankings" VALUES ("2023-02-05");
INSERT INTO "rankings" VALUES ("2023-02-12");
INSERT INTO "rankings" VALUES ("2023-02-19");
INSERT INTO "rankings" VALUES ("2023-02-26");
INSERT INTO "rankings" VALUES ("2023-03-05");