-- MySQL Script generated by MySQL Workbench
-- seg 27 mai 2024 15:03:33
-- 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 db_sanjatour
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema db_sanjatour
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `db_sanjatour` DEFAULT CHARACTER SET utf8 ;
USE `db_sanjatour` ;

-- -----------------------------------------------------
-- Table `db_sanjatour`.`tb_carousel`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `db_sanjatour`.`tb_carousel` (
  `cd_carousel` INT NOT NULL AUTO_INCREMENT,
  `url_imagem` VARCHAR(150) NOT NULL,
  `nm_titulo` VARCHAR(60) NOT NULL,
  `ds_carousel` TEXT NOT NULL,
  `st_carousel` CHAR(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`cd_carousel`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `db_sanjatour`.`tb_service`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `db_sanjatour`.`tb_service` (
  `cd_service` INT NOT NULL AUTO_INCREMENT,
  `nm_service` VARCHAR(60) NOT NULL,
  `ds_service` TEXT NOT NULL,
  `url_imagem` VARCHAR(150) NOT NULL,
  PRIMARY KEY (`cd_service`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `db_sanjatour`.`tb_hotel`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `db_sanjatour`.`tb_hotel` (
  `cd_hotel` INT NOT NULL AUTO_INCREMENT,
  `nm_hotel` VARCHAR(45) NOT NULL,
  `ds_hotel` TEXT NOT NULL,
  `nm_endereco` VARCHAR(60) NOT NULL,
  `nm_bairro` VARCHAR(45) NOT NULL,
  `nm_cidade` VARCHAR(45) NOT NULL,
  `ds_ponto_referencia` VARCHAR(100) NULL,
  `url_imagem` VARCHAR(150) NOT NULL,
  PRIMARY KEY (`cd_hotel`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `db_sanjatour`.`tb_imagem_hotel`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `db_sanjatour`.`tb_imagem_hotel` (
  `cd_imagem_hotel` INT NOT NULL AUTO_INCREMENT,
  `url_imagem_hotel` VARCHAR(150) NOT NULL,
  `id_hotel` INT NOT NULL,
  PRIMARY KEY (`cd_imagem_hotel`),
  INDEX `fk_tb_imagem_hotel_tb_hotel_idx` (`id_hotel` ASC) ,
  CONSTRAINT `fk_tb_imagem_hotel_tb_hotel`
    FOREIGN KEY (`id_hotel`)
    REFERENCES `db_sanjatour`.`tb_hotel` (`cd_hotel`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `db_sanjatour`.`tb_restaurant`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `db_sanjatour`.`tb_restaurant` (
  `cd_restaurant` INT NOT NULL AUTO_INCREMENT,
  `nm_restaurant` VARCHAR(60) NOT NULL,
  `ds_restaurant` TEXT NOT NULL,
  `nm_endereco` VARCHAR(60) NOT NULL,
  `nm_bairro` VARCHAR(45) NOT NULL,
  `nm_cidade` VARCHAR(45) NOT NULL,
  `ds_ponto_referencia` VARCHAR(45) NULL,
  `url_imagem` VARCHAR(150) NOT NULL,
  PRIMARY KEY (`cd_restaurant`))
ENGINE = InnoDB;

create table tb_category_restaurant (
cd_category_rest int primary key auto_increment,
nm_category_rest varchar(50) not null
);

alter table tb_restaurant add id_category_rest int not null;
alter table tb_restaurant add foreign key (id_category_rest) references tb_category_restaurant (cd_category_rest);

-- -----------------------------------------------------
-- Table `db_sanjatour`.`tb_imagem_restaurant`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `db_sanjatour`.`tb_imagem_restaurant` (
  `cd_imagem_restaurant` INT NOT NULL,
  `url_imagem_restaurant` VARCHAR(150) NOT NULL,
  `id_restaurant` INT NOT NULL,
  PRIMARY KEY (`cd_imagem_restaurant`),
  INDEX `fk_tb_imagem_restaurant_tb_restaurant1_idx` (`id_restaurant` ASC) ,
  CONSTRAINT `fk_tb_imagem_restaurant_tb_restaurant1`
    FOREIGN KEY (`id_restaurant`)
    REFERENCES `db_sanjatour`.`tb_restaurant` (`cd_restaurant`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `db_sanjatour`.`tb_destination`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `db_sanjatour`.`tb_destination` (
  `cd_destination` INT NOT NULL AUTO_INCREMENT,
  `nm_destination` VARCHAR(60) NOT NULL,
  `ds_destination` TEXT NOT NULL,
  `nm_endereco` VARCHAR(60) NOT NULL,
  `nm_bairro` VARCHAR(45) NOT NULL,
  `nm_cidade` VARCHAR(45) NOT NULL,
  `url_imagem` VARCHAR(150) NOT NULL,
  PRIMARY KEY (`cd_destination`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `db_sanjatour`.`tb_image_destination`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `db_sanjatour`.`tb_image_destination` (
  `cd_image_destination` INT NOT NULL,
  `url_image_destination` VARCHAR(150) NOT NULL,
  `id_destination` INT NOT NULL,
  PRIMARY KEY (`cd_image_destination`),
  INDEX `fk_tb_image_destination_tb_destination1_idx` (`id_destination` ASC) ,
  CONSTRAINT `fk_tb_image_destination_tb_destination1`
    FOREIGN KEY (`id_destination`)
    REFERENCES `db_sanjatour`.`tb_destination` (`cd_destination`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE TABLE tb_user (
  cd_user int auto_increment,
  nm_user varchar(60) not null,
  nm_email varchar(60) not null unique,
  cd_password varchar(64) not null,
  dt_register_user datetime not null default current_timestamp,
  primary key (cd_user)
);

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;