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-08 00:00:00");
INSERT INTO "Match" VALUES ("2", "2015-08-09 00:00:00");
INSERT INTO "Match" VALUES ("3", "2015-08-10 00:00:00");
INSERT INTO "Match" VALUES ("4", "2015-08-11 00:00:00");
INSERT INTO "Match" VALUES ("5", "2015-08-12 00:00:00");
INSERT INTO "Player" VALUES ("1", "100001", "Aaron Doran", "200001");
INSERT INTO "Player" VALUES ("2", "100002", "John Doe", "200002");
INSERT INTO "Player" VALUES ("3", "100003", "Jane Smith", "200003");
INSERT INTO "Player" VALUES ("4", "100004", "Aaron Ramsey", "200004");
INSERT INTO "Player" VALUES ("5", "100005", "David Beckham", "200005");
INSERT INTO "Player_Attributes" VALUES ("1", "200001", "100001", "2015-08-01 00:00:00", "70", "75");
INSERT INTO "Player_Attributes" VALUES ("2", "200001", "100001", "2015-09-01 00:00:00", "72", "76");
INSERT INTO "Player_Attributes" VALUES ("3", "200001", "100001", "2015-10-01 00:00:00", "68", "74");
INSERT INTO "Player_Attributes" VALUES ("4", "200002", "100002", "2015-08-01 00:00:00", "85", "90");
INSERT INTO "Player_Attributes" VALUES ("5", "200003", "100003", "2015-08-01 00:00:00", "78", "82");
INSERT INTO "Player_Attributes" VALUES ("6", "200001", "100001", "2016-01-01 00:00:00", "71", "75");
INSERT INTO "Player_Attributes" VALUES ("7", "200004", "100004", "2015-08-01 00:00:00", "80", "85");
INSERT INTO "Player_Attributes" VALUES ("8", "200005", "100005", "2015-08-01 00:00:00", "90", "92");