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 "Country" (
"id" INT UNIQUE,
"name" TEXT,
PRIMARY KEY ("id")
);

CREATE TABLE "Match" (
"id" INT,
"country_id" INT,
"league_id" INT,
"home_team_api_id" INT,
"away_team_api_id" INT,
"home_team_goal" INT,
"away_team_goal" INT,
PRIMARY KEY ("id"),
FOREIGN KEY ("away_team_api_id") REFERENCES "Team"("team_api_id"),
FOREIGN KEY ("home_team_api_id") REFERENCES "Team"("team_api_id"),
FOREIGN KEY ("country_id") REFERENCES "Country"("id")
);

CREATE TABLE "Team" (
"id" INT,
"team_api_id" INT UNIQUE,
"team_long_name" TEXT,
PRIMARY KEY ("id")
);



INSERT INTO "Country" VALUES ("1", "Italy");
INSERT INTO "Country" VALUES ("2", "Spain");
INSERT INTO "Country" VALUES ("3", "Germany");
INSERT INTO "Team" VALUES ("1", "1001", "Parma");
INSERT INTO "Team" VALUES ("2", "1002", "Juventus");
INSERT INTO "Team" VALUES ("3", "1003", "AC Milan");
INSERT INTO "Team" VALUES ("4", "1004", "Inter Milan");
INSERT INTO "Team" VALUES ("5", "1005", "Barcelona");
INSERT INTO "Team" VALUES ("6", "1006", "Real Madrid");
INSERT INTO "Team" VALUES ("7", "1007", "Bayern Munich");
INSERT INTO "Team" VALUES ("8", "1008", "Borussia Dortmund");
INSERT INTO "Match" VALUES ("1", "1", "101", "1002", "1001", "2", "1");
INSERT INTO "Match" VALUES ("2", "1", "101", "1003", "1001", "3", "2");
INSERT INTO "Match" VALUES ("3", "1", "101", "1004", "1001", "1", "0");
INSERT INTO "Match" VALUES ("4", "1", "101", "1001", "1002", "1", "1");
INSERT INTO "Match" VALUES ("5", "1", "101", "1001", "1003", "0", "0");
INSERT INTO "Match" VALUES ("6", "2", "201", "1005", "1001", "4", "3");
INSERT INTO "Match" VALUES ("7", "3", "301", "1007", "1001", "2", "2");
INSERT INTO "Match" VALUES ("8", "1", "101", "1002", "1003", "2", "1");
INSERT INTO "Match" VALUES ("9", "1", "101", "1003", "1004", "1", "1");
INSERT INTO "Match" VALUES ("10", "1", "101", "1004", "1001", "3", "0");