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,
"loser_rank" 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,
"hand" TEXT,
"birth_date" DATE,
PRIMARY KEY ("player_id")
);





INSERT INTO "players" VALUES ("1", "R", "1990-05-12");
INSERT INTO "players" VALUES ("2", "L", "1988-11-23");
INSERT INTO "players" VALUES ("3", "R", "1995-07-30");
INSERT INTO "players" VALUES ("4", "L", "1992-01-15");
INSERT INTO "players" VALUES ("5", "R", "1985-03-10");
INSERT INTO "players" VALUES ("6", "L", "1998-12-05");
INSERT INTO "players" VALUES ("7", "R", "1991-09-20");
INSERT INTO "players" VALUES ("8", "L", "1987-06-25");
INSERT INTO "matches" VALUES ("30.5", "2", "15", "28.0", "1", "5");
INSERT INTO "matches" VALUES ("25.0", "3", "40", "27.5", "4", "20");
INSERT INTO "matches" VALUES ("33.0", "5", "10", "22.0", "6", "50");
INSERT INTO "matches" VALUES ("29.0", "7", "25", "31.0", "8", "8");
INSERT INTO "matches" VALUES ("24.5", "6", "60", "26.0", "3", "35");
INSERT INTO "matches" VALUES ("28.0", "1", "12", "30.0", "5", "7");
INSERT INTO "matches" VALUES ("27.0", "4", "18", "29.5", "7", "15");
INSERT INTO "matches" VALUES ("31.5", "8", "9", "24.0", "2", "30");