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

CREATE TABLE "Player_Attributes" (
"id" INT,
"player_api_id" INT,
"date" TEXT,
"overall_rating" INT,
"potential" INT,
"crossing" INT,
PRIMARY KEY ("id"),
FOREIGN KEY ("player_api_id") REFERENCES "Player"("player_api_id")
);



INSERT INTO "Player" VALUES ("1", "100001", "Kevin Constant");
INSERT INTO "Player" VALUES ("2", "100002", "Lionel Messi");
INSERT INTO "Player" VALUES ("3", "100003", "Cristiano Ronaldo");
INSERT INTO "Player" VALUES ("4", "100004", "Neymar Jr.");
INSERT INTO "Player" VALUES ("5", "100005", "Kevin De Bruyne");
INSERT INTO "Player" VALUES ("6", "100006", "Eden Hazard");
INSERT INTO "Player_Attributes" VALUES ("1", "100001", "2013-01-01", "75", "80", "70");
INSERT INTO "Player_Attributes" VALUES ("2", "100001", "2013-07-01", "76", "81", "72");
INSERT INTO "Player_Attributes" VALUES ("3", "100001", "2014-01-01", "77", "82", "75");
INSERT INTO "Player_Attributes" VALUES ("4", "100001", "2014-07-01", "78", "82", "75");
INSERT INTO "Player_Attributes" VALUES ("5", "100001", "2015-01-01", "79", "83", "78");
INSERT INTO "Player_Attributes" VALUES ("6", "100001", "2015-07-01", "79", "83", "78");
INSERT INTO "Player_Attributes" VALUES ("7", "100001", "2016-01-01", "78", "82", "76");
INSERT INTO "Player_Attributes" VALUES ("8", "100002", "2014-01-01", "93", "95", "85");
INSERT INTO "Player_Attributes" VALUES ("9", "100003", "2014-01-01", "92", "92", "80");
INSERT INTO "Player_Attributes" VALUES ("10", "100001", "2012-01-01", "74", "79", "68");
INSERT INTO "Player_Attributes" VALUES ("11", "100001", "2016-07-01", "77", "81", "78");
INSERT INTO "Match" VALUES ("1", "100001");
INSERT INTO "Match" VALUES ("2", "100002");
INSERT INTO "Match" VALUES ("3", "100003");
INSERT INTO "Match" VALUES ("4", "100001");
INSERT INTO "Match" VALUES ("5", "100004");