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,
"date" TEXT,
"overall_rating" INT,
"crossing" 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", "Alexis", "2001", "1988-12-19");
INSERT INTO "Player" VALUES ("2", "1002", "Ariel Borysiuk", "2002", "1991-07-29");
INSERT INTO "Player" VALUES ("3", "1003", "Arouna Kone", "2003", "1983-11-11");
INSERT INTO "Player" VALUES ("4", "1004", "Lionel Messi", "2004", "1987-06-24");
INSERT INTO "Player" VALUES ("5", "1005", "Cristiano Ronaldo", "2005", "1985-02-05");
INSERT INTO "Player" VALUES ("6", "1006", "Neymar Jr.", "2006", "1992-02-05");
INSERT INTO "Player_Attributes" VALUES ("1", "2001", "1001", "2015-01-01", "85", "75");
INSERT INTO "Player_Attributes" VALUES ("2", "2001", "1001", "2016-01-01", "86", "78");
INSERT INTO "Player_Attributes" VALUES ("3", "2002", "1002", "2015-01-01", "70", "60");
INSERT INTO "Player_Attributes" VALUES ("4", "2002", "1002", "2016-01-01", "71", "62");
INSERT INTO "Player_Attributes" VALUES ("5", "2003", "1003", "2015-01-01", "78", "70");
INSERT INTO "Player_Attributes" VALUES ("6", "2003", "1003", "2016-01-01", "79", "72");
INSERT INTO "Player_Attributes" VALUES ("7", "2001", "1001", "2014-01-01", "84", "73");
INSERT INTO "Player_Attributes" VALUES ("8", "2002", "1002", "2014-01-01", "69", "58");
INSERT INTO "Player_Attributes" VALUES ("9", "2003", "1003", "2014-01-01", "77", "68");
INSERT INTO "Player_Attributes" VALUES ("10", "2004", "1004", "2016-01-01", "94", "85");
INSERT INTO "Player_Attributes" VALUES ("11", "2005", "1005", "2016-01-01", "93", "80");
INSERT INTO "Player_Attributes" VALUES ("12", "2006", "1006", "2016-01-01", "90", "79");
INSERT INTO "Match" VALUES ("1", "1001");
INSERT INTO "Match" VALUES ("2", "1002");
INSERT INTO "Match" VALUES ("3", "1003");
INSERT INTO "Match" VALUES ("4", "1004");
INSERT INTO "Match" VALUES ("5", "1005");