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

CREATE TABLE "Match" (
"id" INT,
"league_id" INT,
"season" TEXT,
"date" TEXT,
"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 ("league_id") REFERENCES "League"("id")
);

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



INSERT INTO "League" VALUES ("1", "35", "Scotland Premier League");
INSERT INTO "League" VALUES ("2", "81", "English Premier League");
INSERT INTO "League" VALUES ("3", "13", "La Liga");
INSERT INTO "Team" VALUES ("1", "1001", "Celtic FC");
INSERT INTO "Team" VALUES ("2", "1002", "Rangers FC");
INSERT INTO "Team" VALUES ("3", "1003", "Aberdeen FC");
INSERT INTO "Team" VALUES ("4", "1004", "Hearts FC");
INSERT INTO "Team" VALUES ("5", "1005", "Hibernian FC");
INSERT INTO "Team" VALUES ("6", "2001", "Manchester United");
INSERT INTO "Team" VALUES ("7", "2002", "Chelsea FC");
INSERT INTO "Match" VALUES ("1", "1", "2009/2010", "2001-08-15", "1001", "1002", "0", "2");
INSERT INTO "Match" VALUES ("2", "1", "2009/2010", "2009-09-10", "1003", "1002", "1", "3");
INSERT INTO "Match" VALUES ("3", "1", "2009/2010", "2010-03-20", "1004", "1002", "0", "1");
INSERT INTO "Match" VALUES ("4", "1", "2009/2010", "2009-10-05", "1003", "1001", "0", "1");
INSERT INTO "Match" VALUES ("5", "1", "2009/2010", "2010-04-10", "1005", "1001", "1", "2");
INSERT INTO "Match" VALUES ("6", "1", "2009/2010", "2009-11-15", "1004", "1003", "0", "1");
INSERT INTO "Match" VALUES ("7", "1", "2009/2010", "2009-12-01", "1005", "1004", "2", "2");
INSERT INTO "Match" VALUES ("8", "1", "2009/2010", "2010-02-20", "1001", "1004", "3", "1");
INSERT INTO "Match" VALUES ("9", "2", "2009/2010", "2009-08-15", "2001", "2002", "1", "0");
INSERT INTO "Match" VALUES ("10", "3", "2009/2010", "2009-09-10", "3001", "3002", "2", "2");
INSERT INTO "Match" VALUES ("11", "1", "2010/2011", "2010-08-15", "1001", "1002", "1", "1");