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,
"away_player_1" INT,
PRIMARY KEY ("id"),
FOREIGN KEY ("away_player_1") REFERENCES "Player"("player_api_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,
"ball_control" 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")
);



INSERT INTO "Player" VALUES ("1", "100001", "Abdou Diallo", "1001");
INSERT INTO "Player" VALUES ("2", "100002", "Aaron Appindangoye", "1002");
INSERT INTO "Player" VALUES ("3", "100003", "Lionel Messi", "1003");
INSERT INTO "Player" VALUES ("4", "100004", "Cristiano Ronaldo", "1004");
INSERT INTO "Player" VALUES ("5", "100005", "Neymar Jr", "1005");
INSERT INTO "Player_Attributes" VALUES ("1", "1001", "100001", "75", "70");
INSERT INTO "Player_Attributes" VALUES ("2", "1001", "100001", "76", "72");
INSERT INTO "Player_Attributes" VALUES ("3", "1001", "100001", "77", "71");
INSERT INTO "Player_Attributes" VALUES ("4", "1002", "100002", "68", "60");
INSERT INTO "Player_Attributes" VALUES ("5", "1002", "100002", "69", "62");
INSERT INTO "Player_Attributes" VALUES ("6", "1002", "100002", "70", "61");
INSERT INTO "Player_Attributes" VALUES ("7", "1003", "100003", "94", "96");
INSERT INTO "Player_Attributes" VALUES ("8", "1004", "100004", "93", "92");
INSERT INTO "Player_Attributes" VALUES ("9", "1005", "100005", "92", "95");
INSERT INTO "Player_Attributes" VALUES ("10", "1001", "100001", "78", "73");
INSERT INTO "Player_Attributes" VALUES ("11", "1002", "100002", "71", "63");
INSERT INTO "Match" VALUES ("1", "100001", "100002");
INSERT INTO "Match" VALUES ("2", "100003", "100001");
INSERT INTO "Match" VALUES ("3", "100002", "100004");
INSERT INTO "Match" VALUES ("4", "100005", "100002");
INSERT INTO "Match" VALUES ("5", "100001", "100003");