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

CREATE TABLE "Player_Attributes" (
"id" INT,
"player_fifa_api_id" INT,
"player_api_id" INT,
"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")
);



INSERT INTO "Player" VALUES ("1", "101", "Ariel Borysiuk", "201", "180");
INSERT INTO "Player" VALUES ("2", "102", "John Smith", "202", "175");
INSERT INTO "Player" VALUES ("3", "103", "Carlos Mendez", "203", "178");
INSERT INTO "Player" VALUES ("4", "104", "Luca Rossi", "204", "182");
INSERT INTO "Player" VALUES ("5", "105", "David Johnson", "205", "185");
INSERT INTO "Player_Attributes" VALUES ("1", "201", "101", "75", "80");
INSERT INTO "Player_Attributes" VALUES ("2", "202", "102", "70", "65");
INSERT INTO "Player_Attributes" VALUES ("3", "203", "103", "78", "72");
INSERT INTO "Player_Attributes" VALUES ("4", "204", "104", "82", "85");
INSERT INTO "Player_Attributes" VALUES ("5", "205", "105", "77", "60");
INSERT INTO "Match" VALUES ("1", "101");
INSERT INTO "Match" VALUES ("2", "102");
INSERT INTO "Match" VALUES ("3", "103");
INSERT INTO "Match" VALUES ("4", "104");
INSERT INTO "Match" VALUES ("5", "105");