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

CREATE TABLE "Player_Attributes" (
"id" INT,
"player_fifa_api_id" INT,
"player_api_id" INT,
"overall_rating" INT,
"long_shots" 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", "1001", "Ahmed Samir Farag", "5001", "1990-05-15");
INSERT INTO "Player" VALUES ("2", "1002", "John Doe", "5002", "1988-11-23");
INSERT INTO "Player" VALUES ("3", "1003", "Jane Smith", "5003", "1992-07-30");
INSERT INTO "Player_Attributes" VALUES ("1", "5001", "1001", "75", "30");
INSERT INTO "Player_Attributes" VALUES ("2", "5001", "1001", "78", "40");
INSERT INTO "Player_Attributes" VALUES ("3", "5001", "1001", "80", "50");
INSERT INTO "Player_Attributes" VALUES ("4", "5002", "1002", "65", "20");
INSERT INTO "Player_Attributes" VALUES ("5", "5003", "1003", "70", "25");
INSERT INTO "Match" VALUES ("1", "1001");
INSERT INTO "Match" VALUES ("2", "1002");
INSERT INTO "Match" VALUES ("3", "1001");
INSERT INTO "Match" VALUES ("4", "1003");
INSERT INTO "Match" VALUES ("5", "1001");