DROP TABLE  "compareListPlayers";
DROP TABLE  "compareList";
DROP TABLE  "averageStats";
DROP TABLE  "combatStats";
DROP TABLE  "gameStats";
DROP TABLE  "heroStats";
DROP TABLE  "hero";
DROP TABLE  "player";
DROP TABLE  "role";
DROP TABLE  "title";

CREATE TABLE "player" (
  "playerID" VARCHAR(255) PRIMARY KEY NOT NULL,
  "name" VARCHAR(255),
  "titleID" INT,
  "updated" TIMESTAMP,
  "nemisisPlayerID" INT
);

CREATE TABLE "hero" (
  "heroID" INT PRIMARY KEY NOT NULL,
  "roleID" INT NOT NULL,
  "name" VARCHAR(255)
);

CREATE TABLE "heroStats" (
  "heroStatsID" INT PRIMARY KEY NOT NULL,
  "playerID" VARCHAR(255) NOT NULL,
  "heroID" INT NOT NULL
);

CREATE TABLE "gameStats" (
  "heroStatsID" INT NOT NULL,
  "timePlayed" INT,
  "gamesPlayed" INT,
  "gamesWon" INT,
  "winPercentage" INT,
  "gamesLost" INT
);

CREATE TABLE "combatStats" (
  "heroStatsID" INT NOT NULL,
  "eliminations" INT,
  "deaths" INT,
  "finalBlows" INT,
  "heroDamageDone" INT,
  "healingDone" INT,
  "timeOnFire" INT,
  "weaponAccuracy" INT
);

CREATE TABLE "averageStats" (
  "heroStatsID" INT NOT NULL,
  "eliminationsPerLife" FLOAT,
  "eliminationsPer10min" INT,
  "deathsPer10min" INT,
  "finalBlowsPer10min" INT,
  "heroDamagePer10min" INT,
  "healingPer10min" INT
);

CREATE TABLE "role" (
  "roleID" INT PRIMARY KEY NOT NULL,
  "name" VARCHAR(255)
);

CREATE TABLE "title" (
  "titleID" INT PRIMARY KEY NOT NULL,
  "name" VARCHAR(255)
);

CREATE TABLE "compareList" (
  "compareListID" INT PRIMARY KEY NOT NULL,
  "name" VARCHAR(255)
);

CREATE TABLE "compareListPlayers" (
  "compareListID" INT,
  "playerID" VARCHAR(255) NOT NULL
);

ALTER TABLE "heroStats" ADD FOREIGN KEY ("heroID") REFERENCES "hero" ("heroID");

ALTER TABLE "heroStats" ADD FOREIGN KEY ("playerID") REFERENCES "player" ("playerID");

ALTER TABLE "gameStats" ADD FOREIGN KEY ("heroStatsID") REFERENCES "heroStats" ("heroStatsID");

ALTER TABLE "combatStats" ADD FOREIGN KEY ("heroStatsID") REFERENCES "heroStats" ("heroStatsID");

ALTER TABLE "averageStats" ADD FOREIGN KEY ("heroStatsID") REFERENCES "heroStats" ("heroStatsID");

ALTER TABLE "hero" ADD FOREIGN KEY ("roleID") REFERENCES "role" ("roleID");

--ALTER TABLE "player" ADD FOREIGN KEY ("playerID") REFERENCES "player" ("nemisisPlayerID");

ALTER TABLE "player" ADD FOREIGN KEY ("titleID") REFERENCES "title" ("titleID");

ALTER TABLE "compareListPlayers" ADD FOREIGN KEY ("compareListID") REFERENCES "compareList" ("compareListID");

ALTER TABLE "compareListPlayers" ADD FOREIGN KEY ("playerID") REFERENCES "player" ("playerID");
--