Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (67 sloc) 2.35 KB
-- MySQL Script generated by MySQL Workbench
-- 11/24/16 13:23:58
-- 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 patio
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `patio` ;
-- -----------------------------------------------------
-- Schema patio
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `patio` DEFAULT CHARACTER SET utf8 ;
USE `patio` ;
-- -----------------------------------------------------
-- Table `patio`.`users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `patio`.`users` (
`email` VARCHAR(50) NOT NULL,
`id` INT NOT NULL AUTO_INCREMENT,
`confirmed` BOOL NOT NULL DEFAULT FALSE,
`code` VARCHAR(5) NOT NULL,
`pass_md5_hex` VARCHAR(32) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `patio`.`restaurants`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `patio`.`restaurants` (
`name` VARCHAR(50) NOT NULL,
`lat` DOUBLE NOT NULL,
`long` DOUBLE NOT NULL,
`id` INT NOT NULL AUTO_INCREMENT,
`cuisine` VARCHAR(45) NOT NULL,
`indoor` TINYINT(1) NOT NULL,
`outdoor` TINYINT(1) NOT NULL,
`days` BIT(7) NULL,
`open` TIME NULL,
`close` TIME NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `patio`.`reservations`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `patio`.`reservations` (
`id` INT NOT NULL AUTO_INCREMENT,
`restaurant` INT NOT NULL,
`user` INT NOT NULL,
`time` DATETIME NOT NULL,
`number` INT NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
ALTER TABLE reservations
ADD CONSTRAINT FK_restaurant
FOREIGN KEY (restaurant) REFERENCES restaurants(id)
ON UPDATE CASCADE
ON DELETE CASCADE;
ALTER TABLE reservations
ADD CONSTRAINT FK_user
FOREIGN KEY (user) REFERENCES users(id)
ON UPDATE CASCADE
ON DELETE CASCADE;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
You can’t perform that action at this time.