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,
"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,
"long_passing" 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", "Player A", "200001", "1980-01-15");
INSERT INTO "Player" VALUES ("2", "100002", "Player B", "200002", "1985-03-20");
INSERT INTO "Player" VALUES ("3", "100003", "Player C", "200003", "1978-11-01");
INSERT INTO "Player" VALUES ("4", "100004", "Player D", "200004", "1990-07-25");
INSERT INTO "Player" VALUES ("5", "100005", "Player E", "200005", "1980-01-15");
INSERT INTO "Player" VALUES ("6", "100006", "Player F", "200006", "1978-11-01");
INSERT INTO "Player_Attributes" VALUES ("1", "200001", "100001", "2015-01-01", "85", "70");
INSERT INTO "Player_Attributes" VALUES ("2", "200002", "100002", "2015-01-01", "78", "65");
INSERT INTO "Player_Attributes" VALUES ("3", "200003", "100003", "2015-01-01", "90", "80");
INSERT INTO "Player_Attributes" VALUES ("4", "200004", "100004", "2015-01-01", "75", "60");
INSERT INTO "Player_Attributes" VALUES ("5", "200001", "100001", "2016-01-01", "86", "72");
INSERT INTO "Player_Attributes" VALUES ("6", "200003", "100003", "2016-01-01", "91", "82");
INSERT INTO "Player_Attributes" VALUES ("7", "200005", "100005", "2015-01-01", "83", "75");
INSERT INTO "Player_Attributes" VALUES ("8", "200006", "100006", "2015-01-01", "88", "78");