text: -- MySQL Script generated by MySQL Workbench
  -- 01/17/18 08:52:05
  -- 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 examen
  -- -----------------------------------------------------
  
  -- -----------------------------------------------------
  -- Schema examen
  -- -----------------------------------------------------
  CREATE SCHEMA IF NOT EXISTS `examen` DEFAULT CHARACTER SET utf8 ;
  USE `examen` ;
  
  -- -----------------------------------------------------
  -- Table `examen`.`rijbewijstype`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`rijbewijstype` (
    `rijbewijs_typenummer` INT NOT NULL,
    `rijbewijs_type` VARCHAR(30) NULL,
    PRIMARY KEY (`rijbewijs_typenummer`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `examen`.`rijbewijs`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`rijbewijs` (
    `rijbewijsnummer` INT NOT NULL,
    `rijbewijs_typenummer` INT NOT NULL,
    `rijbewijs_afgifte` DATETIME NULL,
    `rijbewijs_geldigtot` DATETIME NULL,
    PRIMARY KEY (`rijbewijsnummer`),
    UNIQUE INDEX `rijbewijsnummer_UNIQUE` (`rijbewijsnummer` ASC),
    INDEX `rijbewijs_typenummer_idx` (`rijbewijs_typenummer` ASC),
    CONSTRAINT `rijbewijs_typenummer`
      FOREIGN KEY (`rijbewijs_typenummer`)
      REFERENCES `examen`.`rijbewijstype` (`rijbewijs_typenummer`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `examen`.`adressen`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`adressen` (
    `adres` VARCHAR(45) NULL,
    `postcode` VARCHAR(45) NOT NULL,
    `woonplaats` VARCHAR(45) NULL,
    PRIMARY KEY (`postcode`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `examen`.`accountgegevens`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`accountgegevens` (
    `gebruikersnaam` VARCHAR(45) NOT NULL,
    `email` VARCHAR(45) NULL,
    `wachtwoord` VARCHAR(45) NULL,
    `status` TINYINT(1) NULL,
    PRIMARY KEY (`gebruikersnaam`),
    UNIQUE INDEX `gebruikersnaam_UNIQUE` (`gebruikersnaam` ASC))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `examen`.`klantgegevens`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`klantgegevens` (
    `gebruikersnaam` VARCHAR(45) NOT NULL,
    `klantgegevenscol` VARCHAR(45) NULL,
    `postcode` VARCHAR(45) NOT NULL,
    `voorletters` VARCHAR(45) NULL,
    `tussenvoegsel` VARCHAR(45) NULL,
    `achternaam` VARCHAR(45) NULL,
    `telefoonnummer` INT NULL,
    `mobiel` INT NULL,
    `rijbewijsnummer` INT NOT NULL,
    `id` INT NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `rijbewijsummer_idx` (`rijbewijsnummer` ASC),
    UNIQUE INDEX `rijbewijsnummer_UNIQUE` (`rijbewijsnummer` ASC),
    INDEX `postcode_idx` (`postcode` ASC),
    UNIQUE INDEX `klant_id_UNIQUE` (`gebruikersnaam` ASC),
    CONSTRAINT `rijbewijsummer`
      FOREIGN KEY (`rijbewijsnummer`)
      REFERENCES `examen`.`rijbewijs` (`rijbewijsnummer`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `postcode`
      FOREIGN KEY (`postcode`)
      REFERENCES `examen`.`adressen` (`postcode`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `gebruikersnaam`
      FOREIGN KEY (`gebruikersnaam`)
      REFERENCES `examen`.`accountgegevens` (`gebruikersnaam`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `examen`.`test`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`test` (
    `test_id` INT NOT NULL AUTO_INCREMENT,
    `test_datum` DATETIME NULL,
    `test_tijd` DATETIME NULL,
    `geslaagd` TINYINT(1) NULL,
    PRIMARY KEY (`test_id`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `examen`.`objectimage`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`objectimage` (
    `imageid` INT NOT NULL AUTO_INCREMENT,
    `imagelink` VARCHAR(120) NULL,
    PRIMARY KEY (`imageid`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `examen`.`object`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`object` (
    `object_id` INT NOT NULL AUTO_INCREMENT,
    `kenteken` VARCHAR(45) NULL,
    `chassinummer` VARCHAR(45) NULL,
    `object_type` VARCHAR(45) NULL,
    `merk` VARCHAR(45) NULL,
    `type` VARCHAR(45) NULL,
    `bouwjaar` YEAR NULL,
    `mass_inventaris` INT NULL,
    `massa_max` INT NULL,
    `lengte_tot` INT NULL,
    `lengte_opbouw` INT NULL,
    `hoogte` INT NULL,
    `rijbewijs_benodigd` VARCHAR(45) NULL,
    `prijs_dag` INT NULL,
    `prijs_week` INT NULL,
    `imageid` INT NULL,
    PRIMARY KEY (`object_id`),
    INDEX `imageid_idx` (`imageid` ASC),
    CONSTRAINT `imageid`
      FOREIGN KEY (`imageid`)
      REFERENCES `examen`.`objectimage` (`imageid`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `examen`.`ordernummer`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`ordernummer` (
    `ordernummer` INT NOT NULL,
    `klant_id` INT NOT NULL,
    `test_id` INT NOT NULL,
    `object_id` INT NOT NULL,
    `orderdatum` DATETIME NULL,
    `datum_uit` DATETIME NULL,
    `datum_terug` DATETIME NULL,
    PRIMARY KEY (`ordernummer`),
    INDEX `accountgegevens_id_idx` (`klant_id` ASC),
    INDEX `test_id_idx` (`test_id` ASC),
    INDEX `object_id_idx` (`object_id` ASC),
    CONSTRAINT `accountgegevens_id`
      FOREIGN KEY (`klant_id`)
      REFERENCES `examen`.`accountgegevens` (`gebruikersnaam`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `test_id`
      FOREIGN KEY (`test_id`)
      REFERENCES `examen`.`test` (`test_id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `object_id`
      FOREIGN KEY (`object_id`)
      REFERENCES `examen`.`object` (`object_id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `examen`.`optie`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`optie` (
    `optie_id` INT NOT NULL,
    `omschrijving` VARCHAR(45) NULL,
    `prijs` INT NULL,
    `datum_uit` DATETIME NULL,
    `datum_terug` DATETIME NULL,
    PRIMARY KEY (`optie_id`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `examen`.`optieregel`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `examen`.`optieregel` (
    `optie_id` INT NOT NULL,
    `ordernummer` INT NULL,
    PRIMARY KEY (`optie_id`),
    INDEX `ordernummer_idx` (`ordernummer` ASC),
    CONSTRAINT `ordernummer`
      FOREIGN KEY (`ordernummer`)
      REFERENCES `examen`.`ordernummer` (`ordernummer`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `optie_id`
      FOREIGN KEY (`optie_id`)
      REFERENCES `examen`.`optie` (`optie_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;
  