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

CREATE TABLE "players" (
"player_id" INT UNIQUE,
"birth_date" DATE,
PRIMARY KEY ("player_id")
);

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





INSERT INTO "players" VALUES ("1", "1990-05-12");
INSERT INTO "players" VALUES ("2", "1988-11-23");
INSERT INTO "players" VALUES ("3", "1995-07-30");
INSERT INTO "players" VALUES ("4", "1992-01-15");
INSERT INTO "players" VALUES ("5", "1985-09-05");
INSERT INTO "players" VALUES ("6", "1993-12-20");
INSERT INTO "players" VALUES ("7", "1991-03-10");
INSERT INTO "players" VALUES ("8", "1989-06-25");
INSERT INTO "rankings" VALUES ("2023-01-01", "1", "5");
INSERT INTO "rankings" VALUES ("2023-01-01", "2", "3");
INSERT INTO "rankings" VALUES ("2023-01-01", "3", "7");
INSERT INTO "rankings" VALUES ("2023-01-01", "4", "2");
INSERT INTO "rankings" VALUES ("2023-02-01", "1", "6");
INSERT INTO "rankings" VALUES ("2023-02-01", "2", "4");
INSERT INTO "rankings" VALUES ("2023-02-01", "5", "8");
INSERT INTO "rankings" VALUES ("2023-02-01", "6", "1");
INSERT INTO "rankings" VALUES ("2023-03-01", "3", "9");
INSERT INTO "rankings" VALUES ("2023-03-01", "4", "3");
INSERT INTO "rankings" VALUES ("2023-03-01", "7", "2");
INSERT INTO "rankings" VALUES ("2023-03-01", "8", "4");
INSERT INTO "matches" VALUES ("5", "3");
INSERT INTO "matches" VALUES ("2", "1");
INSERT INTO "matches" VALUES ("4", "6");
INSERT INTO "matches" VALUES ("7", "8");
INSERT INTO "matches" VALUES ("3", "2");
INSERT INTO "matches" VALUES ("1", "4");
INSERT INTO "matches" VALUES ("8", "5");
INSERT INTO "matches" VALUES ("6", "7");