-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdb.sql
More file actions
186 lines (164 loc) · 7.73 KB
/
db.sql
File metadata and controls
186 lines (164 loc) · 7.73 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
-- --------------------------------------------------------
-- Servidor: 127.0.0.1
-- Versão do servidor: 10.4.13-MariaDB-1:10.4.13+maria~focal - mariadb.org binary distribution
-- OS do Servidor: debian-linux-gnu
-- HeidiSQL Versão: 11.0.0.5919
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-- Copiando estrutura do banco de dados para myDB
DROP DATABASE IF EXISTS `myDB`;
CREATE DATABASE IF NOT EXISTS `myDB` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `myDB`;
-- Copiando estrutura para tabela myDB.address
DROP TABLE IF EXISTS `address`;
CREATE TABLE IF NOT EXISTS `address` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cep` varchar(255) NOT NULL,
`street` varchar(255) NOT NULL,
`number` int(11) NOT NULL,
`complement` varchar(255) DEFAULT NULL,
`reference` varchar(255) DEFAULT NULL,
`nickname` varchar(255) DEFAULT NULL,
`latitude` double(22,0) DEFAULT NULL,
`longitude` double(22,0) DEFAULT NULL,
`assistance_id` int(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_assistance_id` (`assistance_id`) USING BTREE,
CONSTRAINT `address_fk` FOREIGN KEY (`assistance_id`) REFERENCES `assistance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=utf8mb4;
-- Exportação de dados foi desmarcado.
-- Copiando estrutura para tabela myDB.assistance
DROP TABLE IF EXISTS `assistance`;
CREATE TABLE IF NOT EXISTS `assistance` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`owner_id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`total_vacancies` int(11) NOT NULL,
`available` tinyint(1) NOT NULL DEFAULT 1,
`available_vacancies` int(10) unsigned NOT NULL DEFAULT 0,
`description` text NOT NULL,
`date` datetime NOT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
`course_id` int(11) DEFAULT NULL,
`suspended_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `course_id` (`course_id`) USING BTREE,
KEY `owner_id` (`owner_id`) USING BTREE,
CONSTRAINT `assistance_ibfk_2` FOREIGN KEY (`owner_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `assistance_ibfk_3` FOREIGN KEY (`course_id`) REFERENCES `course` (`id`) ON DELETE SET NULL ON UPDATE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=1025 DEFAULT CHARSET=utf8mb4;
-- Exportação de dados foi desmarcado.
-- Copiando estrutura para tabela myDB.assistance_presence_list
DROP TABLE IF EXISTS `assistance_presence_list`;
CREATE TABLE IF NOT EXISTS `assistance_presence_list` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`student_id` int(11) NOT NULL,
`assistance_id` int(11) NOT NULL,
`assistant_rating` float DEFAULT NULL,
`student_rating` float DEFAULT NULL,
`student_presence` tinyint(4) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `id` (`id`) USING BTREE,
KEY `student_id` (`student_id`) USING BTREE,
KEY `ibfk_3` (`assistance_id`),
CONSTRAINT `ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `ibfk_3` FOREIGN KEY (`assistance_id`) REFERENCES `assistance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=54 DEFAULT CHARSET=utf8mb4;
-- Exportação de dados foi desmarcado.
-- Copiando estrutura para tabela myDB.assistance_tag
DROP TABLE IF EXISTS `assistance_tag`;
CREATE TABLE IF NOT EXISTS `assistance_tag` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`assistance_id` int(11) NOT NULL,
`tag_id` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `assistance_id` (`assistance_id`) USING BTREE,
KEY `tag_id` (`tag_id`) USING BTREE,
CONSTRAINT `assistance_tag_ibfk_1` FOREIGN KEY (`assistance_id`) REFERENCES `assistance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `assistance_tag_ibfk_2` FOREIGN KEY (`tag_id`) REFERENCES `tag` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=384 DEFAULT CHARSET=utf8mb4;
-- Exportação de dados foi desmarcado.
-- Copiando estrutura para tabela myDB.course
DROP TABLE IF EXISTS `course`;
CREATE TABLE IF NOT EXISTS `course` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`number_semesters` int(11) DEFAULT NULL,
`description` text DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4;
-- Exportação de dados foi desmarcado.
-- Copiando estrutura para tabela myDB.subject
DROP TABLE IF EXISTS `subject`;
CREATE TABLE IF NOT EXISTS `subject` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`description` text DEFAULT NULL,
`code` varchar(50) DEFAULT NULL,
`course_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `subject_fk` (`course_id`),
CONSTRAINT `subject_fk` FOREIGN KEY (`course_id`) REFERENCES `course` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4;
-- Exportação de dados foi desmarcado.
-- Copiando estrutura para tabela myDB.subject_course
DROP TABLE IF EXISTS `subject_course`;
CREATE TABLE IF NOT EXISTS `subject_course` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`course_id` int(11) NOT NULL,
`subject_id` int(11) NOT NULL,
`semester` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `course_id` (`course_id`) USING BTREE,
KEY `subject_id` (`subject_id`) USING BTREE,
CONSTRAINT `subject_course_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `course` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `subject_course_ibfk_2` FOREIGN KEY (`subject_id`) REFERENCES `subject` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Exportação de dados foi desmarcado.
-- Copiando estrutura para tabela myDB.tag
DROP TABLE IF EXISTS `tag`;
CREATE TABLE IF NOT EXISTS `tag` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`description` mediumtext DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=159 DEFAULT CHARSET=utf8mb4;
-- Exportação de dados foi desmarcado.
-- Copiando estrutura para tabela myDB.user
DROP TABLE IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`full_name` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
`is_assistant` tinyint(1) NOT NULL DEFAULT 0,
`course_id` int(11) DEFAULT NULL,
`cpf` varchar(255) DEFAULT NULL,
`matricula` varchar(255) DEFAULT NULL,
`idUFFS` varchar(255) DEFAULT NULL,
`assistant_stars` float(12,0) NOT NULL DEFAULT 10,
`student_stars` float(12,0) NOT NULL DEFAULT 10,
`email` varchar(255) DEFAULT NULL,
`phone_number` varchar(255) DEFAULT NULL,
`password` varchar(255) NOT NULL,
`verified_assistant` tinyint(1) NOT NULL DEFAULT 0,
`profile_picture` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `cpf` (`cpf`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `idUFFS` (`idUFFS`),
UNIQUE KEY `matricula` (`matricula`),
UNIQUE KEY `phone_number` (`phone_number`),
KEY `course_id` (`course_id`) USING BTREE,
CONSTRAINT `user_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `course` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=utf8mb4;
-- Exportação de dados foi desmarcado.
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;