-
Notifications
You must be signed in to change notification settings - Fork 2
/
db.sql
executable file
·167 lines (147 loc) · 5.65 KB
/
db.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
-- 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 peleja
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema peleja
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `peleja` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `peleja` ;
-- -----------------------------------------------------
-- Table `peleja`.`Credencial`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `peleja`.`Credencial` (
`id` VARCHAR(36) NOT NULL,
`nome` VARCHAR(255) NOT NULL,
`senha` VARCHAR(255) NOT NULL,
`email` VARCHAR(255) NOT NULL,
`facebook` VARCHAR(255) NULL,
`twitter` VARCHAR(255) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `peleja`.`Organizador`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `peleja`.`Organizador` (
`Credencial_id` VARCHAR(36) NOT NULL,
PRIMARY KEY (`Credencial_id`),
CONSTRAINT `fk_Organizador_Credencial`
FOREIGN KEY (`Credencial_id`)
REFERENCES `peleja`.`Credencial` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `peleja`.`Participante`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `peleja`.`Participante` (
`Credencial_id` VARCHAR(36) NOT NULL,
PRIMARY KEY (`Credencial_id`),
CONSTRAINT `fk_Participante_Credencial1`
FOREIGN KEY (`Credencial_id`)
REFERENCES `peleja`.`Credencial` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `peleja`.`Palestrante`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `peleja`.`Palestrante` (
`Credencial_id` VARCHAR(36) NOT NULL,
PRIMARY KEY (`Credencial_id`),
CONSTRAINT `fk_Palestrante_Credencial1`
FOREIGN KEY (`Credencial_id`)
REFERENCES `peleja`.`Credencial` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `peleja`.`Evento`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `peleja`.`Evento` (
`id` INT NOT NULL AUTO_INCREMENT,
`nome` VARCHAR(255) NULL,
`dataInicioInscricao` DATETIME NULL,
`dataFimInscricao` DATETIME NULL,
`dataEvento` DATETIME NULL,
`limiteParticipantes` INT NULL,
`localEvento` VARCHAR(255) NULL,
`logradouro` VARCHAR(255) NULL,
`numero` VARCHAR(255) NULL,
`bairro` VARCHAR(255) NULL,
`cidade` VARCHAR(255) NULL,
`estado` VARCHAR(255) NULL,
`cep` INT NULL,
`Organizador_Credencial_id` VARCHAR(36) NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_Evento_Organizador1_idx` (`Organizador_Credencial_id` ASC),
CONSTRAINT `fk_Evento_Organizador1`
FOREIGN KEY (`Organizador_Credencial_id`)
REFERENCES `peleja`.`Organizador` (`Credencial_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `peleja`.`Inscricao`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `peleja`.`Inscricao` (
`Participante_Credencial_id` VARCHAR(36) NOT NULL,
`Evento_id` INT NOT NULL,
PRIMARY KEY (`Participante_Credencial_id`, `Evento_id`),
INDEX `fk_Inscricao_Evento_idx` (`Evento_id` ASC),
INDEX `fk_Inscricao_Participante_idx` (`Participante_Credencial_id` ASC),
CONSTRAINT `fk_Participante_has_Evento_Participante1`
FOREIGN KEY (`Participante_Credencial_id`)
REFERENCES `peleja`.`Participante` (`Credencial_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Participante_has_Evento_Evento1`
FOREIGN KEY (`Evento_id`)
REFERENCES `peleja`.`Evento` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `peleja`.`Palestra`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `peleja`.`Palestra` (
`id` INT NOT NULL AUTO_INCREMENT,
`titulo` VARCHAR(255) NULL,
`resumo` BLOB NULL,
`Palestrante_Credencial_id` VARCHAR(36) NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_Palestra_Palestrante_idx` (`Palestrante_Credencial_id` ASC),
CONSTRAINT `fk_Palestra_Palestrante1`
FOREIGN KEY (`Palestrante_Credencial_id`)
REFERENCES `peleja`.`Palestrante` (`Credencial_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `peleja`.`Submissao`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `peleja`.`Submissao` (
`Palestra_id` INT NOT NULL,
`Evento_id` INT NOT NULL,
`Aceita` TINYINT(1) NULL,
`Votos` INT NULL,
PRIMARY KEY (`Palestra_id`, `Evento_id`),
INDEX `fk_Submisao_Evento_idx` (`Evento_id` ASC),
INDEX `fk_Submisao_Palestra_idx` (`Palestra_id` ASC),
CONSTRAINT `fk_Palestra_has_Evento_Palestra1`
FOREIGN KEY (`Palestra_id`)
REFERENCES `peleja`.`Palestra` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Palestra_has_Evento_Evento1`
FOREIGN KEY (`Evento_id`)
REFERENCES `peleja`.`Evento` (`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;