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

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

CREATE TABLE "Player_Attributes" (
"id" INT,
"player_fifa_api_id" INT,
"player_api_id" INT,
"date" TEXT,
"overall_rating" INT,
"potential" 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", "2015-08-01 00:00:00");
INSERT INTO "Match" VALUES ("2", "2015-08-08 00:00:00");
INSERT INTO "Match" VALUES ("3", "2015-08-15 00:00:00");
INSERT INTO "Match" VALUES ("4", "2015-08-22 00:00:00");
INSERT INTO "Match" VALUES ("5", "2015-08-29 00:00:00");
INSERT INTO "Player" VALUES ("1", "10001", "Dorlan Pabon", "200001");
INSERT INTO "Player" VALUES ("2", "10002", "Lionel Messi", "200002");
INSERT INTO "Player" VALUES ("3", "10003", "Cristiano Ronaldo", "200003");
INSERT INTO "Player" VALUES ("4", "10004", "Neymar Jr", "200004");
INSERT INTO "Player" VALUES ("5", "10005", "Dorlan Pabon", "200005");
INSERT INTO "Player" VALUES ("6", "10006", "Eden Hazard", "200006");
INSERT INTO "Player_Attributes" VALUES ("1", "200001", "10001", "2015-01-01 00:00:00", "75", "80");
INSERT INTO "Player_Attributes" VALUES ("2", "200001", "10001", "2015-07-01 00:00:00", "78", "82");
INSERT INTO "Player_Attributes" VALUES ("3", "200001", "10001", "2016-01-01 00:00:00", "80", "83");
INSERT INTO "Player_Attributes" VALUES ("4", "200002", "10002", "2015-01-01 00:00:00", "92", "95");
INSERT INTO "Player_Attributes" VALUES ("5", "200003", "10003", "2015-01-01 00:00:00", "90", "93");
INSERT INTO "Player_Attributes" VALUES ("6", "200001", "10001", "2014-01-01 00:00:00", "72", "78");
INSERT INTO "Player_Attributes" VALUES ("7", "200005", "10005", "2015-01-01 00:00:00", "70", "75");
INSERT INTO "Player_Attributes" VALUES ("8", "200005", "10005", "2015-07-01 00:00:00", "73", "77");