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_player_1" INT,
PRIMARY KEY ("id"),
FOREIGN KEY ("home_player_1") REFERENCES "Player"("player_api_id")
);

CREATE TABLE "Player" (
"id" INT,
"player_api_id" INT UNIQUE,
"player_name" TEXT,
"player_fifa_api_id" INT UNIQUE,
PRIMARY KEY ("id")
);

CREATE TABLE "Player_Attributes" (
"id" INT,
"player_fifa_api_id" INT,
"player_api_id" INT,
"date" TEXT,
"overall_rating" INT,
"heading_accuracy" INT,
PRIMARY KEY ("id"),
FOREIGN KEY ("player_api_id") REFERENCES "Player"("player_api_id"),
FOREIGN KEY ("player_fifa_api_id") REFERENCES "Player"("player_fifa_api_id")
);

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



INSERT INTO "Player" VALUES ("1", "1001", "Francois Affolter", "2001");
INSERT INTO "Player" VALUES ("2", "1002", "Lionel Messi", "2002");
INSERT INTO "Player" VALUES ("3", "1003", "Cristiano Ronaldo", "2003");
INSERT INTO "Player" VALUES ("4", "1004", "Neymar Jr.", "2004");
INSERT INTO "Player" VALUES ("5", "1005", "Kylian Mbappe", "2005");
INSERT INTO "Player" VALUES ("6", "1006", "Robert Lewandowski", "2006");
INSERT INTO "Player" VALUES ("7", "1007", "Sergio Ramos", "2007");
INSERT INTO "Player" VALUES ("8", "1008", "Virgil van Dijk", "2008");
INSERT INTO "Player_Attributes" VALUES ("1", "2001", "1001", "2014-09-18 00:00:00", "75", "80");
INSERT INTO "Player_Attributes" VALUES ("2", "2001", "1001", "2015-01-01 00:00:00", "76", "81");
INSERT INTO "Player_Attributes" VALUES ("3", "2002", "1002", "2014-09-18 00:00:00", "92", "60");
INSERT INTO "Player_Attributes" VALUES ("4", "2003", "1003", "2014-09-18 00:00:00", "93", "85");
INSERT INTO "Player_Attributes" VALUES ("5", "2001", "1001", "2014-09-17 00:00:00", "74", "79");
INSERT INTO "Player_Attributes" VALUES ("6", "2004", "1004", "2014-09-18 00:00:00", "88", "65");
INSERT INTO "Player_Attributes" VALUES ("7", "2001", "1001", "2014-10-01 00:00:00", "75", "80");
INSERT INTO "Player_Attributes" VALUES ("8", "2007", "1007", "2014-09-18 00:00:00", "89", "90");
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 "Team" VALUES ("1", "FC Basel");
INSERT INTO "Team" VALUES ("2", "Barcelona");
INSERT INTO "Team" VALUES ("3", "Real Madrid");
INSERT INTO "Team" VALUES ("4", "Paris Saint-Germain");
INSERT INTO "Team" VALUES ("5", "Bayern Munich");