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

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

CREATE TABLE "Player_Attributes" (
"id" INT,
"player_fifa_api_id" INT,
"player_api_id" INT,
"date" TEXT,
"defensive_work_rate" TEXT,
"interceptions" 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 "Match" VALUES ("1", "1001");
INSERT INTO "Match" VALUES ("2", "1002");
INSERT INTO "Match" VALUES ("3", "1003");
INSERT INTO "Player" VALUES ("1", "5001", "David Wilson", "7001", "180");
INSERT INTO "Player" VALUES ("2", "5002", "John Smith", "7002", "175");
INSERT INTO "Player" VALUES ("3", "5003", "Michael Brown", "7003", "185");
INSERT INTO "Player" VALUES ("4", "5004", "David Wilson", "7004", "178");
INSERT INTO "Player_Attributes" VALUES ("1", "7001", "5001", "2023-01-01", "High", "30");
INSERT INTO "Player_Attributes" VALUES ("2", "7001", "5001", "2023-06-01", "Medium", "25");
INSERT INTO "Player_Attributes" VALUES ("3", "7002", "5002", "2023-01-01", "Low", "10");
INSERT INTO "Player_Attributes" VALUES ("4", "7003", "5003", "2023-01-01", "Medium", "20");
INSERT INTO "Player_Attributes" VALUES ("5", "7004", "5004", "2023-01-01", "Low", "15");
INSERT INTO "Player_Attributes" VALUES ("6", "7004", "5004", "2023-07-01", "High", "35");