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 "Match" (
"id" INT,
"home_team_api_id" INT,
PRIMARY KEY ("id"),
FOREIGN KEY ("home_team_api_id") REFERENCES "Team"("team_api_id")
);

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

CREATE TABLE "Team_Attributes" (
"id" INT,
"team_fifa_api_id" INT,
"team_api_id" INT,
"date" TEXT,
"buildUpPlaySpeed" INT,
"buildUpPlayDribblingClass" TEXT,
"chanceCreationPassing" INT,
PRIMARY KEY ("id"),
FOREIGN KEY ("team_api_id") REFERENCES "Team"("team_api_id"),
FOREIGN KEY ("team_fifa_api_id") REFERENCES "Team"("team_fifa_api_id")
);



INSERT INTO "Team" VALUES ("1", "1001", "2001", "FC Barcelona", "BAR");
INSERT INTO "Team" VALUES ("2", "1002", "2002", "Real Madrid CF", "RMA");
INSERT INTO "Team" VALUES ("3", "1003", "2003", "Manchester United", "MUN");
INSERT INTO "Team" VALUES ("4", "1004", "2004", "Bayern Munich", "BAY");
INSERT INTO "Team" VALUES ("5", "1005", "2005", "Juventus", "JUV");
INSERT INTO "Team" VALUES ("6", "1006", "2006", "Paris Saint-Germain", "PSG");
INSERT INTO "Team_Attributes" VALUES ("1", "2001", "1001", "2014-01-05 12:00:00", "70", "Normal", "75");
INSERT INTO "Team_Attributes" VALUES ("2", "2002", "1002", "2014-01-10 15:00:00", "65", "Normal", "60");
INSERT INTO "Team_Attributes" VALUES ("3", "2003", "1003", "2014-01-15 18:00:00", "80", "Normal", "55");
INSERT INTO "Team_Attributes" VALUES ("4", "2004", "1004", "2014-01-20 20:00:00", "75", "Fast", "85");
INSERT INTO "Team_Attributes" VALUES ("5", "2005", "1005", "2014-01-25 14:00:00", "60", "Normal", "50");
INSERT INTO "Team_Attributes" VALUES ("6", "2006", "1006", "2014-01-30 16:00:00", "68", "Slow", "70");
INSERT INTO "Team_Attributes" VALUES ("7", "2001", "1001", "2013-12-31 23:59:59", "72", "Normal", "80");
INSERT INTO "Team_Attributes" VALUES ("8", "2002", "1002", "2014-02-01 00:00:01", "66", "Normal", "65");
INSERT INTO "Match" VALUES ("1", "1001");
INSERT INTO "Match" VALUES ("2", "1002");
INSERT INTO "Match" VALUES ("3", "1003");
INSERT INTO "Match" VALUES ("4", "1004");
INSERT INTO "Match" VALUES ("5", "1005");
INSERT INTO "Match" VALUES ("6", "1006");