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

CREATE TABLE "Player_Attributes" (
"id" INT,
"player_api_id" INT,
"crossing" INT,
"long_passing" INT,
PRIMARY KEY ("id"),
FOREIGN KEY ("player_api_id") REFERENCES "Player"("player_api_id")
);



INSERT INTO "Player" VALUES ("1", "1001", "Aaron Lennox");
INSERT INTO "Player" VALUES ("2", "1002", "John Doe");
INSERT INTO "Player" VALUES ("3", "1003", "Jane Smith");
INSERT INTO "Player" VALUES ("4", "1004", "Aaron Ramsey");
INSERT INTO "Player" VALUES ("5", "1005", "David Beckham");
INSERT INTO "Player_Attributes" VALUES ("1", "1001", "75", "80");
INSERT INTO "Player_Attributes" VALUES ("2", "1001", "70", "78");
INSERT INTO "Player_Attributes" VALUES ("3", "1002", "60", "65");
INSERT INTO "Player_Attributes" VALUES ("4", "1003", "85", "90");
INSERT INTO "Player_Attributes" VALUES ("5", "1001", "68", "72");
INSERT INTO "Player_Attributes" VALUES ("6", "1004", "70", "75");
INSERT INTO "Player_Attributes" VALUES ("7", "1005", "95", "98");
INSERT INTO "Match" VALUES ("1", "1001", "1002");
INSERT INTO "Match" VALUES ("2", "1003", "1001");
INSERT INTO "Match" VALUES ("3", "1004", "1005");
INSERT INTO "Match" VALUES ("4", "1002", "1003");
INSERT INTO "Match" VALUES ("5", "1001", "1004");