-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabela_mysql.txt
66 lines (57 loc) · 1.99 KB
/
tabela_mysql.txt
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
Link Etherpad
https://public.etherpad-mozilla.org/p/bcd20162
USE bcd;
DROP TABLE IF EXISTS matricula;
DROP TABLE IF EXISTS curso;
DROP TABLE IF EXISTS curriculo;
DROP TABLE IF EXISTS disciplina;
DROP TABLE IF EXISTS aluno;
DROP TABLE IF EXISTS campus;
CREATE TABLE IF NOT EXISTS campus(
id tinyint unsigned auto_increment primary key,
nome varchar(128) unique not null
);
CREATE TABLE IF NOT EXISTS aluno(
id int unsigned auto_increment primary key,
nome varchar(128) not null,
documento char(11) unique not null,
telefone bigint unsigned,
email varchar(128)
);
CREATE TABLE IF NOT EXISTS disciplina(
id smallint unsigned auto_increment primary key,
codigo char(8) unique not null,
nome char(100) not null,
CH tinyint unsigned not null,
CHmin smallint unsigned not null
);
CREATE TABLE IF NOT EXISTS curso(
id smallint unsigned auto_increment primary key,
numero smallint unsigned unique not null,
CHmin smallint unsigned not null,
CHmax smallint unsigned not null,
nome varchar(128) not null,
campus tinyint unsigned not null,
constraint fk_curso_campus_campus_id
foreign key(campus) references campus(id)
);
CREATE TABLE IF NOT EXISTS curriculo(
id smallint unsigned auto_increment primary key,
curso smallint unsigned,
implantacao date not null,
disciplina smallint unsigned not null,
constraint fk_curriculo_curso_curso_id
foreign key(curso) references curso(id),
constraint fk_curriculo_disciplina_disciplina_id
foreign key(disciplina) references disciplina(id)
);
CREATE TABLE IF NOT EXISTS matricula(
id int unsigned auto_increment primary key,
numero bigint unsigned unique not null,
aluno int unsigned not null,
curso smallint unsigned not null,
constraint fk_matricula_aluno_aluno_id
foreign key(aluno) references aluno(id),
constraint fk_matricula_curso_curso_id
foreign key(curso) references curso(id)
);