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_age" FLOAT,
"loser_id" INT,
"winner_age" FLOAT,
"winner_id" INT,
"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,
"birth_date" DATE,
PRIMARY KEY ("player_id")
);

CREATE TABLE "rankings" (
"ranking_points" INT
);





INSERT INTO "players" VALUES ("1", "1990-05-20");
INSERT INTO "players" VALUES ("2", "1985-11-15");
INSERT INTO "players" VALUES ("3", "1992-07-30");
INSERT INTO "players" VALUES ("4", "1988-01-10");
INSERT INTO "players" VALUES ("5", "1995-12-05");
INSERT INTO "players" VALUES ("6", "1991-03-22");
INSERT INTO "players" VALUES ("7", "1987-09-17");
INSERT INTO "players" VALUES ("8", "1993-06-01");
INSERT INTO "matches" VALUES ("30.5", "1", "34.2", "2", "5");
INSERT INTO "matches" VALUES ("28.0", "3", "32.5", "4", "12");
INSERT INTO "matches" VALUES ("26.7", "5", "29.8", "6", "20");
INSERT INTO "matches" VALUES ("33.1", "7", "27.4", "8", "8");
INSERT INTO "matches" VALUES ("31.0", "2", "28.3", "3", "15");
INSERT INTO "matches" VALUES ("29.5", "4", "30.0", "1", "3");
INSERT INTO "matches" VALUES ("27.8", "6", "31.2", "5", "10");
INSERT INTO "matches" VALUES ("34.0", "8", "26.5", "7", "7");
INSERT INTO "rankings" VALUES ("1000");
INSERT INTO "rankings" VALUES ("850");
INSERT INTO "rankings" VALUES ("1200");
INSERT INTO "rankings" VALUES ("950");
INSERT INTO "rankings" VALUES ("1100");
INSERT INTO "rankings" VALUES ("1050");
INSERT INTO "rankings" VALUES ("900");
INSERT INTO "rankings" VALUES ("1150");