-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExercicio2_1_2.sql
49 lines (41 loc) · 1.81 KB
/
Exercicio2_1_2.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- 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 exercicio_af_02
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema exercicio_af_02
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `exercicio_af_02` DEFAULT CHARACTER SET utf8 ;
USE `exercicio_af_02` ;
-- -----------------------------------------------------
-- Table `exercicio_af_02`.`clientes`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exercicio_af_02`.`clientes` (
`cli_id` INT NOT NULL AUTO_INCREMENT,
`cli_nome` VARCHAR(300) NOT NULL,
`cli_email` VARCHAR(100) NULL,
`cli_total_pedidos` DECIMAL(8,2) NULL,
PRIMARY KEY (`cli_id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `exercicio_af_02`.`pedidos`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exercicio_af_02`.`pedidos` (
`pdd_id` INT NOT NULL AUTO_INCREMENT,
`pdd_data` DATE NOT NULL,
`pdd_valor` DECIMAL(5,2) NOT NULL,
`pdd_cli_id` INT NOT NULL,
PRIMARY KEY (`pdd_id`),
INDEX `fk_pedidos_clientes_idx` (`pdd_cli_id` ASC) VISIBLE,
CONSTRAINT `fk_pedidos_clientes`
FOREIGN KEY (`pdd_cli_id`)
REFERENCES `exercicio_af_02`.`clientes` (`cli_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;