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", "ESP");
INSERT INTO "players" VALUES ("3", "FRA");
INSERT INTO "players" VALUES ("4", "GER");
INSERT INTO "players" VALUES ("5", "RUS");
INSERT INTO "players" VALUES ("6", "USA");
INSERT INTO "players" VALUES ("7", "BRA");
INSERT INTO "players" VALUES ("8", "JPN");
INSERT INTO "players" VALUES ("9", "ESP");
INSERT INTO "players" VALUES ("10", "ITA");
INSERT INTO "players" VALUES ("11", "GER");
INSERT INTO "players" VALUES ("12", "CHN");
INSERT INTO "players" VALUES ("13", "AUS");
INSERT INTO "players" VALUES ("14", "FRA");
INSERT INTO "players" VALUES ("15", "CAN");
INSERT INTO "matches" VALUES ("2", "ESP", "1");
INSERT INTO "matches" VALUES ("3", "FRA", "2");
INSERT INTO "matches" VALUES ("4", "GER", "3");
INSERT INTO "matches" VALUES ("5", "RUS", "4");
INSERT INTO "matches" VALUES ("6", "USA", "5");
INSERT INTO "matches" VALUES ("7", "BRA", "6");
INSERT INTO "matches" VALUES ("8", "JPN", "7");
INSERT INTO "matches" VALUES ("9", "ESP", "8");
INSERT INTO "matches" VALUES ("10", "ITA", "9");
INSERT INTO "matches" VALUES ("11", "GER", "10");
INSERT INTO "matches" VALUES ("12", "CHN", "11");
INSERT INTO "matches" VALUES ("13", "AUS", "12");
INSERT INTO "matches" VALUES ("14", "FRA", "13");
INSERT INTO "matches" VALUES ("15", "CAN", "14");
INSERT INTO "matches" VALUES ("1", "USA", "15");