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

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 "League" VALUES ("1", "100");
INSERT INTO "League" VALUES ("2", "200");
INSERT INTO "Team" VALUES ("1", "101", "1001", "Manchester United", "Man Utd");
INSERT INTO "Team" VALUES ("2", "102", "1002", "Real Madrid", "Real");
INSERT INTO "Team" VALUES ("3", "103", "1003", "Bayern Munich", "Bayern");
INSERT INTO "Team" VALUES ("4", "104", "1004", "Juventus", "Juve");
INSERT INTO "Team" VALUES ("5", "105", "1005", "Paris Saint-Germain", "PSG");
INSERT INTO "Team" VALUES ("6", "106", "1006", "Chelsea", "Chelsea");
INSERT INTO "Team" VALUES ("7", "107", "1007", "Barcelona", "Barca");
INSERT INTO "Team" VALUES ("8", "108", "1008", "Liverpool", "Liverpool");
INSERT INTO "Match" VALUES ("1", "101");
INSERT INTO "Match" VALUES ("2", "102");
INSERT INTO "Match" VALUES ("3", "103");
INSERT INTO "Match" VALUES ("4", "104");
INSERT INTO "Match" VALUES ("5", "105");
INSERT INTO "Match" VALUES ("6", "106");
INSERT INTO "Match" VALUES ("7", "107");
INSERT INTO "Match" VALUES ("8", "108");
INSERT INTO "Team_Attributes" VALUES ("1", "1001", "101", "2023-01-01", "85", "80");
INSERT INTO "Team_Attributes" VALUES ("2", "1002", "102", "2023-01-01", "90", "85");
INSERT INTO "Team_Attributes" VALUES ("3", "1003", "103", "2023-01-01", "88", "82");
INSERT INTO "Team_Attributes" VALUES ("4", "1004", "104", "2023-01-01", "87", "83");
INSERT INTO "Team_Attributes" VALUES ("5", "1005", "105", "2023-01-01", "80", "78");
INSERT INTO "Team_Attributes" VALUES ("6", "1006", "106", "2023-01-01", "75", "70");
INSERT INTO "Team_Attributes" VALUES ("7", "1007", "107", "2023-01-01", "90", "88");
INSERT INTO "Team_Attributes" VALUES ("8", "1008", "108", "2023-01-01", "70", "65");