text: -- MySQL Script generated by MySQL Workbench
  -- 04/01/16 16:14:34
  -- 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='TRADITIONAL,ALLOW_INVALID_DATES';
  
  -- -----------------------------------------------------
  -- Schema blend_db
  -- -----------------------------------------------------
  
  -- -----------------------------------------------------
  -- Schema blend_db
  -- -----------------------------------------------------
  CREATE SCHEMA IF NOT EXISTS `blend_db` DEFAULT CHARACTER SET utf8 ;
  USE `blend_db` ;
  
  -- -----------------------------------------------------
  -- Table `blend_db`.`User`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `blend_db`.`User` ;
  
  CREATE TABLE IF NOT EXISTS `blend_db`.`User` (
    `idUser` INT NOT NULL AUTO_INCREMENT,
    `Username` VARCHAR(45) NOT NULL,
    `password` CHAR(64) NOT NULL,
    `salt` CHAR(64) NOT NULL,
    `email` VARCHAR(45) NOT NULL,
    `phone` VARCHAR(45) NULL,
    `lender_rating` DECIMAL NOT NULL,
    `total_lend_ratings` INT NOT NULL,
    `borrower_rating` DECIMAL NOT NULL,
    `total_borrow_ratings` INT NOT NULL,
    `profile_url` VARCHAR(100) NULL,
    `first_name` VARCHAR(45) NOT NULL,
    `last_name` VARCHAR(45) NOT NULL,
    `address` VARCHAR(120) NOT NULL,
    `latitude` FLOAT NULL,
    `longitude` FLOAT NULL,
    PRIMARY KEY (`idUser`),
    UNIQUE INDEX `Username_UNIQUE` (`Username` ASC))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `blend_db`.`Item`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `blend_db`.`Item` ;
  
  CREATE TABLE IF NOT EXISTS `blend_db`.`Item` (
    `idItem` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NOT NULL,
    `condition` DECIMAL NOT NULL,
    `owner` INT NULL,
    `price` DECIMAL NULL,
    `description` VARCHAR(100) NULL,
    `duration` INT NOT NULL,
    `image` VARCHAR(120) NULL,
    PRIMARY KEY (`idItem`),
    CONSTRAINT `owner`
      FOREIGN KEY (`owner`)
      REFERENCES `blend_db`.`User` (`idUser`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `blend_db`.`Borrows`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `blend_db`.`Borrows` ;
  
  CREATE TABLE IF NOT EXISTS `blend_db`.`Borrows` (
    `idBorrows` INT NOT NULL AUTO_INCREMENT,
    `idUser` INT NOT NULL,
    `idProduct` INT NOT NULL,
    `accepted` TINYINT(1) NOT NULL,
    `finished` TINYINT(1) NOT NULL,
    `inital_date` DATE NOT NULL,
    `borrower_commented` TINYINT(1) NOT NULL,
    `lender_commented` TINYINT(1) NOT NULL,
    PRIMARY KEY (`idBorrows`),
    INDEX `idUser_idx` (`idUser` ASC),
    INDEX `idProduct_idx` (`idProduct` ASC),
    CONSTRAINT `idUser`
      FOREIGN KEY (`idUser`)
      REFERENCES `blend_db`.`User` (`idUser`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `idProduct`
      FOREIGN KEY (`idProduct`)
      REFERENCES `blend_db`.`Item` (`idItem`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  -- -----------------------------------------------------
  -- Table `blend_db`.`sessions`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `blend_db`.`sessions` ;
  CREATE TABLE sessions (
   session_id varchar(255) COLLATE utf8_bin NOT NULL,
   expires int(11) unsigned NOT NULL,
   data text COLLATE utf8_bin,
   PRIMARY KEY (session_id)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
  
  SET SQL_MODE=@OLD_SQL_MODE;
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  