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 "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,
"potential" INT,
"preferred_foot" TEXT,
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", "Aaron Mooy", "5001", "1990-09-15");
INSERT INTO "Player" VALUES ("2", "1002", "John Smith", "5002", "1988-05-20");
INSERT INTO "Player" VALUES ("3", "1003", "David Jones", "5003", "1992-11-30");
INSERT INTO "Player_Attributes" VALUES ("1", "5001", "1001", "2016-02-04 10:00:00", "78", "85", "left");
INSERT INTO "Player_Attributes" VALUES ("2", "5001", "1001", "2016-02-05 15:00:00", "79", "85", "left");
INSERT INTO "Player_Attributes" VALUES ("3", "5002", "1002", "2016-02-04 09:00:00", "70", "75", "right");
INSERT INTO "Player_Attributes" VALUES ("4", "5003", "1003", "2016-02-04 12:00:00", "65", "70", "right");
INSERT INTO "Player_Attributes" VALUES ("5", "5001", "1001", "2015-12-31 08:00:00", "77", "85", "left");