· 6 years ago · Jul 09, 2019, 10:26 PM
1CREATE SCHEMA IF NOT EXISTS `centro_pesquisa` DEFAULT CHARACTER SET utf8 ;
2USE `centro_pesquisa` ;
3
4-- -----------------------------------------------------
5-- Table `centro_pesquisa`.`funcionario`
6-- -----------------------------------------------------
7CREATE TABLE IF NOT EXISTS `centro_pesquisa`.`funcionario` (
8 `id` INT(11) NOT NULL AUTO_INCREMENT,
9 `codigo_id` INT(11) NULL DEFAULT NULL,
10 `nome` VARCHAR(45) NULL DEFAULT NULL,
11 `sexo` VARCHAR(10) NULL DEFAULT NULL,
12 `endereco` VARCHAR(100) NULL DEFAULT NULL,
13 `salario` DECIMAL(10,2) NULL DEFAULT NULL,
14 `dt_aniversario` DATE NULL DEFAULT NULL,
15 PRIMARY KEY (`id`))
16ENGINE = InnoDB
17AUTO_INCREMENT = 5
18DEFAULT CHARACTER SET = utf8;
19
20
21-- -----------------------------------------------------
22-- Table `centro_pesquisa`.`departamento`
23-- -----------------------------------------------------
24CREATE TABLE IF NOT EXISTS `centro_pesquisa`.`departamento` (
25 `id` INT(11) NOT NULL AUTO_INCREMENT,
26 `nome` VARCHAR(45) NULL DEFAULT NULL,
27 `numero` INT(11) NULL DEFAULT NULL,
28 PRIMARY KEY (`id`))
29ENGINE = InnoDB
30AUTO_INCREMENT = 6
31DEFAULT CHARACTER SET = utf8;
32
33
34-- -----------------------------------------------------
35-- Table `centro_pesquisa`.`laboratorio`
36-- -----------------------------------------------------
37CREATE TABLE IF NOT EXISTS `centro_pesquisa`.`laboratorio` (
38 `id` INT(11) NOT NULL AUTO_INCREMENT,
39 `nome` VARCHAR(45) NULL DEFAULT NULL,
40 `custo` DECIMAL(10,2) NULL DEFAULT NULL,
41 `departamento_id` INT(11) NOT NULL,
42 PRIMARY KEY (`id`, `departamento_id`),
43 INDEX `fk_laboratorio_departamento1_idx` (`departamento_id` ASC) VISIBLE,
44 CONSTRAINT `fk_laboratorio_departamento1`
45 FOREIGN KEY (`departamento_id`)
46 REFERENCES `centro_pesquisa`.`departamento` (`id`))
47ENGINE = InnoDB
48AUTO_INCREMENT = 5
49DEFAULT CHARACTER SET = utf8;
50
51
52-- -----------------------------------------------------
53-- Table `centro_pesquisa`.`administrador`
54-- -----------------------------------------------------
55CREATE TABLE IF NOT EXISTS `centro_pesquisa`.`administrador` (
56 `id` INT(11) NOT NULL AUTO_INCREMENT,
57 `escolaridade` VARCHAR(25) NULL DEFAULT NULL,
58 `funcionario_id` INT(11) NOT NULL,
59 `laboratorio_id` INT(11) NOT NULL,
60 PRIMARY KEY (`id`, `funcionario_id`, `laboratorio_id`),
61 INDEX `fk_administrador_funcionario1_idx` (`funcionario_id` ASC) VISIBLE,
62 INDEX `fk_administrador_laboratorio1_idx` (`laboratorio_id` ASC) VISIBLE,
63 CONSTRAINT `fk_administrador_funcionario1`
64 FOREIGN KEY (`funcionario_id`)
65 REFERENCES `centro_pesquisa`.`funcionario` (`id`),
66 CONSTRAINT `fk_administrador_laboratorio1`
67 FOREIGN KEY (`laboratorio_id`)
68 REFERENCES `centro_pesquisa`.`laboratorio` (`id`))
69ENGINE = InnoDB
70AUTO_INCREMENT = 3
71DEFAULT CHARACTER SET = utf8;
72
73
74-- -----------------------------------------------------
75-- Table `centro_pesquisa`.`pesquisador`
76-- -----------------------------------------------------
77CREATE TABLE IF NOT EXISTS `centro_pesquisa`.`pesquisador` (
78 `id` INT(11) NOT NULL AUTO_INCREMENT,
79 `area_atuacao` VARCHAR(45) NULL DEFAULT NULL,
80 `funcionario_id` INT(11) NOT NULL,
81 PRIMARY KEY (`id`, `funcionario_id`),
82 INDEX `fk_pesquisador_funcionario1_idx` (`funcionario_id` ASC) VISIBLE,
83 CONSTRAINT `fk_pesquisador_funcionario1`
84 FOREIGN KEY (`funcionario_id`)
85 REFERENCES `centro_pesquisa`.`funcionario` (`id`))
86ENGINE = InnoDB
87AUTO_INCREMENT = 3
88DEFAULT CHARACTER SET = utf8;
89
90
91-- -----------------------------------------------------
92-- Table `centro_pesquisa`.`projeto`
93-- -----------------------------------------------------
94CREATE TABLE IF NOT EXISTS `centro_pesquisa`.`projeto` (
95 `id` INT(11) NOT NULL AUTO_INCREMENT,
96 `nome` VARCHAR(45) NULL DEFAULT NULL,
97 `numero_id` INT(11) NULL DEFAULT NULL,
98 `periodo_meses` INT(11) NULL DEFAULT NULL,
99 `departamento_id` INT(11) NOT NULL,
100 PRIMARY KEY (`id`, `departamento_id`),
101 INDEX `fk_projeto_departamento1_idx` (`departamento_id` ASC) VISIBLE,
102 CONSTRAINT `fk_projeto_departamento1`
103 FOREIGN KEY (`departamento_id`)
104 REFERENCES `centro_pesquisa`.`departamento` (`id`))
105ENGINE = InnoDB
106AUTO_INCREMENT = 5
107DEFAULT CHARACTER SET = utf8;
108
109
110-- -----------------------------------------------------
111-- Table `centro_pesquisa`.`pesquisador_projeto`
112-- -----------------------------------------------------
113CREATE TABLE IF NOT EXISTS `centro_pesquisa`.`pesquisador_projeto` (
114 `pesquisador_id` INT(11) NOT NULL,
115 `pesquisador_funcionario_id` INT(11) NOT NULL,
116 `projeto_id` INT(11) NOT NULL,
117 `horas_trabalhadas` DECIMAL(10,2) NULL DEFAULT NULL,
118 PRIMARY KEY (`pesquisador_id`, `pesquisador_funcionario_id`, `projeto_id`),
119 INDEX `fk_pesquisador_has_projeto_projeto1_idx` (`projeto_id` ASC) VISIBLE,
120 INDEX `fk_pesquisador_has_projeto_pesquisador1_idx` (`pesquisador_id` ASC, `pesquisador_funcionario_id` ASC) VISIBLE,
121 CONSTRAINT `fk_pesquisador_has_projeto_pesquisador1`
122 FOREIGN KEY (`pesquisador_id` , `pesquisador_funcionario_id`)
123 REFERENCES `centro_pesquisa`.`pesquisador` (`id` , `funcionario_id`),
124 CONSTRAINT `fk_pesquisador_has_projeto_projeto1`
125 FOREIGN KEY (`projeto_id`)
126 REFERENCES `centro_pesquisa`.`projeto` (`id`))
127ENGINE = InnoDB
128DEFAULT CHARACTER SET = utf8;
129
130
131-- -----------------------------------------------------
132-- Table `centro_pesquisa`.`ramal`
133-- -----------------------------------------------------
134CREATE TABLE IF NOT EXISTS `centro_pesquisa`.`ramal` (
135 `id` INT(11) NOT NULL AUTO_INCREMENT,
136 `nome` VARCHAR(45) NULL DEFAULT NULL,
137 `numero` VARCHAR(15) NULL DEFAULT NULL,
138 `departamento_id` INT(11) NOT NULL,
139 PRIMARY KEY (`id`, `departamento_id`),
140 INDEX `fk_ramal_departamento1_idx` (`departamento_id` ASC) VISIBLE,
141 CONSTRAINT `fk_ramal_departamento1`
142 FOREIGN KEY (`departamento_id`)
143 REFERENCES `centro_pesquisa`.`departamento` (`id`))
144ENGINE = InnoDB
145AUTO_INCREMENT = 3
146DEFAULT CHARACTER SET = utf8;