text: -- MySQL Script generated by MySQL Workbench
  -- Wed 17 Oct 2018 15:30:12 CEST
  -- Model: New Model    Version: 1.0
  -- MySQL Workbench Forward Engineering
  
  SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
  
  -- -----------------------------------------------------
  -- Schema default_schema
  -- -----------------------------------------------------
  -- -----------------------------------------------------
  -- Schema boardgamesapp
  -- -----------------------------------------------------
  DROP SCHEMA IF EXISTS `boardgamesapp` ;
  
  -- -----------------------------------------------------
  -- Schema boardgamesapp
  -- -----------------------------------------------------
  CREATE SCHEMA IF NOT EXISTS `boardgamesapp` ;
  USE `boardgamesapp` ;
  
  -- -----------------------------------------------------
  -- Table `boardgamesapp`.`profiles`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `boardgamesapp`.`profiles` ;
  
  CREATE TABLE IF NOT EXISTS `boardgamesapp`.`profiles` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `nickname` VARCHAR(255) NULL DEFAULT NULL,
    `wins` INT NULL DEFAULT NULL,
    `losses` INT NULL DEFAULT NULL,
    `totalGames` INT NULL DEFAULT NULL,
    PRIMARY KEY (`id`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `boardgamesapp`.`users`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `boardgamesapp`.`users` ;
  
  CREATE TABLE IF NOT EXISTS `boardgamesapp`.`users` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `fname` VARCHAR(255) NULL DEFAULT NULL,
    `lname` VARCHAR(255) NULL DEFAULT NULL,
    `email` VARCHAR(255) NULL DEFAULT NULL,
    `password` VARCHAR(255) NULL DEFAULT NULL,
    `rememberMeToken` VARCHAR(255) NULL DEFAULT NULL,
    `forgotPasswordToken` VARCHAR(255) NULL DEFAULT NULL,
    `profiles_id` INT NOT NULL,
    PRIMARY KEY (`id`, `profiles_id`),
    INDEX `fk_users_profiles_idx` (`profiles_id` ASC) ,
    CONSTRAINT `fk_users_profiles`
      FOREIGN KEY (`profiles_id`)
      REFERENCES `boardgamesapp`.`profiles` (`id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `boardgamesapp`.`Games`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `boardgamesapp`.`Games` ;
  
  CREATE TABLE IF NOT EXISTS `boardgamesapp`.`Games` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NULL DEFAULT NULL,
    `description` VARCHAR(5024) NULL DEFAULT NULL,
    PRIMARY KEY (`id`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `boardgamesapp`.`PlayedGames`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `boardgamesapp`.`PlayedGames` ;
  
  CREATE TABLE IF NOT EXISTS `boardgamesapp`.`PlayedGames` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `Games_id` INT NOT NULL,
    `score` INT NULL DEFAULT NULL,
    PRIMARY KEY (`id`, `Games_id`),
    INDEX `fk_PlayedGames_Games1_idx` (`Games_id` ASC) ,
    CONSTRAINT `fk_PlayedGames_Games1`
      FOREIGN KEY (`Games_id`)
      REFERENCES `boardgamesapp`.`Games` (`id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `boardgamesapp`.`PlayedGameUserScore`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `boardgamesapp`.`PlayedGameUserScore` ;
  
  CREATE TABLE IF NOT EXISTS `boardgamesapp`.`PlayedGameUserScore` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `score` INT NULL,
    `PlayedGames_id` INT NOT NULL,
    `users_id` INT NOT NULL,
    PRIMARY KEY (`id`, `PlayedGames_id`, `users_id`),
    INDEX `fk_PlayedGameUserScore_PlayedGames1_idx` (`PlayedGames_id` ASC) ,
    INDEX `fk_PlayedGameUserScore_users1_idx` (`users_id` ASC) ,
    CONSTRAINT `fk_PlayedGameUserScore_PlayedGames1`
      FOREIGN KEY (`PlayedGames_id`)
      REFERENCES `boardgamesapp`.`PlayedGames` (`id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_PlayedGameUserScore_users1`
      FOREIGN KEY (`users_id`)
      REFERENCES `boardgamesapp`.`users` (`id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  SET SQL_MODE=@OLD_SQL_MODE;
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  