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,
"date" TEXT,
"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,
"overall_rating" INT,
"preferred_foot" TEXT,
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")
);



INSERT INTO "Player" VALUES ("1", "1001", "Abdou Diallo", "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", "Eden Hazard", "2006");
INSERT INTO "Player" VALUES ("7", "1007", "Kevin De Bruyne", "2007");
INSERT INTO "Player" VALUES ("8", "1008", "Mohamed Salah", "2008");
INSERT INTO "Player" VALUES ("9", "1009", "Robert Lewandowski", "2009");
INSERT INTO "Player" VALUES ("10", "1010", "Sergio Ramos", "2010");
INSERT INTO "Player_Attributes" VALUES ("1", "2001", "1001", "78", "left");
INSERT INTO "Player_Attributes" VALUES ("2", "2002", "1002", "94", "left");
INSERT INTO "Player_Attributes" VALUES ("3", "2003", "1003", "93", "right");
INSERT INTO "Player_Attributes" VALUES ("4", "2004", "1004", "92", "right");
INSERT INTO "Player_Attributes" VALUES ("5", "2005", "1005", "91", "right");
INSERT INTO "Player_Attributes" VALUES ("6", "2006", "1006", "91", "right");
INSERT INTO "Player_Attributes" VALUES ("7", "2007", "1007", "91", "right");
INSERT INTO "Player_Attributes" VALUES ("8", "2008", "1008", "90", "left");
INSERT INTO "Player_Attributes" VALUES ("9", "2009", "1009", "90", "right");
INSERT INTO "Player_Attributes" VALUES ("10", "2010", "1010", "89", "right");
INSERT INTO "Player_Attributes" VALUES ("11", "2001", "1001", "80", "left");
INSERT INTO "Match" VALUES ("1", "2023-01-15", "1001");
INSERT INTO "Match" VALUES ("2", "2023-01-20", "1002");
INSERT INTO "Match" VALUES ("3", "2023-01-25", "1003");
INSERT INTO "Match" VALUES ("4", "2023-02-01", "1001");
INSERT INTO "Match" VALUES ("5", "2023-02-05", "1004");