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,
"buildUpPlayPassingClass" TEXT,
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", "FC Lorient", "LOR");
INSERT INTO "Team" VALUES ("2", "1002", "5002", "Paris Saint-Germain", "PSG");
INSERT INTO "Team" VALUES ("3", "1003", "5003", "Olympique Lyonnais", "LYO");
INSERT INTO "Team" VALUES ("4", "1004", "5004", "AS Monaco", "MON");
INSERT INTO "Team" VALUES ("5", "1005", "5005", "FC Nantes", "NAN");
INSERT INTO "Team_Attributes" VALUES ("1", "5001", "1001", "2010-02-22 15:00:00", "75", "Medium");
INSERT INTO "Team_Attributes" VALUES ("2", "5001", "1001", "2010-02-21 15:00:00", "70", "Slow");
INSERT INTO "Team_Attributes" VALUES ("3", "5002", "1002", "2010-02-22 15:00:00", "85", "Fast");
INSERT INTO "Team_Attributes" VALUES ("4", "5003", "1003", "2010-02-22 15:00:00", "80", "Medium");
INSERT INTO "Team_Attributes" VALUES ("5", "5004", "1004", "2010-02-22 15:00:00", "78", "Fast");
INSERT INTO "Team_Attributes" VALUES ("6", "5005", "1005", "2010-02-22 15:00:00", "65", "Slow");
INSERT INTO "Team_Attributes" VALUES ("7", "5001", "1001", "2010-02-23 15:00:00", "77", "Medium-Fast");
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");