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,
"buildUpPlayPassing" 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", "5001", "Manchester United FC", "Man Utd");
INSERT INTO "Team" VALUES ("2", "1002", "5002", "Real Madrid CF", "Real Madrid");
INSERT INTO "Team" VALUES ("3", "1003", "5003", "FC Barcelona", "Barcelona");
INSERT INTO "Team" VALUES ("4", "1004", "5004", "Bayern Munich", "Bayern");
INSERT INTO "Team" VALUES ("5", "1005", "5005", "Juventus FC", "Juventus");
INSERT INTO "Team" VALUES ("6", "1006", "5006", "Paris Saint-Germain", "PSG");
INSERT INTO "Team" VALUES ("7", "1007", "5007", "Chelsea FC", "Chelsea");
INSERT INTO "Team" VALUES ("8", "1008", "5008", "AC Milan", "AC Milan");
INSERT INTO "Team_Attributes" VALUES ("1", "5001", "1001", "2012-03-15", "70", "75");
INSERT INTO "Team_Attributes" VALUES ("2", "5002", "1002", "2012-06-20", "65", "80");
INSERT INTO "Team_Attributes" VALUES ("3", "5003", "1003", "2012-09-10", "80", "85");
INSERT INTO "Team_Attributes" VALUES ("4", "5004", "1004", "2012-11-05", "60", "70");
INSERT INTO "Team_Attributes" VALUES ("5", "5005", "1005", "2012-01-25", "75", "60");
INSERT INTO "Team_Attributes" VALUES ("6", "5006", "1006", "2012-12-30", "68", "78");
INSERT INTO "Team_Attributes" VALUES ("7", "5007", "1007", "2012-07-18", "72", "65");
INSERT INTO "Team_Attributes" VALUES ("8", "5008", "1008", "2012-04-22", "66", "55");
INSERT INTO "Team_Attributes" VALUES ("9", "5001", "1001", "2011-12-15", "69", "74");
INSERT INTO "Team_Attributes" VALUES ("10", "5002", "1002", "2013-01-10", "67", "79");
INSERT INTO "Team_Attributes" VALUES ("11", "5003", "1003", "2013-03-05", "81", "86");
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");
INSERT INTO "Match" VALUES ("7", "1007");
INSERT INTO "Match" VALUES ("8", "1008");