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_ioc" TEXT,
"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,
"country_code" TEXT,
PRIMARY KEY ("player_id")
);





INSERT INTO "players" VALUES ("1", "USA");
INSERT INTO "players" VALUES ("2", "USA");
INSERT INTO "players" VALUES ("3", "USA");
INSERT INTO "players" VALUES ("4", "FRA");
INSERT INTO "players" VALUES ("5", "FRA");
INSERT INTO "players" VALUES ("6", "GER");
INSERT INTO "players" VALUES ("7", "GER");
INSERT INTO "players" VALUES ("8", "GER");
INSERT INTO "players" VALUES ("9", "GER");
INSERT INTO "players" VALUES ("10", "ESP");
INSERT INTO "matches" VALUES ("2", "USA", "4");
INSERT INTO "matches" VALUES ("5", "FRA", "1");
INSERT INTO "matches" VALUES ("3", "USA", "6");
INSERT INTO "matches" VALUES ("7", "GER", "2");
INSERT INTO "matches" VALUES ("9", "GER", "3");
INSERT INTO "matches" VALUES ("1", "USA", "8");
INSERT INTO "matches" VALUES ("10", "ESP", "7");
INSERT INTO "matches" VALUES ("4", "FRA", "9");
INSERT INTO "matches" VALUES ("6", "GER", "5");
INSERT INTO "matches" VALUES ("8", "GER", "10");