-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scripts - academico-db.txt
137 lines (113 loc) · 3.81 KB
/
Scripts - academico-db.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
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
CREATE DATABASE "academico-db"
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'Portuguese_Brazil.1252'
LC_CTYPE = 'Portuguese_Brazil.1252'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;
CREATE SEQUENCE public.enderecos_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;
ALTER SEQUENCE public.enderecos_id_seq
OWNER TO postgres;
CREATE SEQUENCE public.notas_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;
ALTER SEQUENCE public.notas_id_seq
OWNER TO postgres;
CREATE TABLE public.enderecos
(
id integer NOT NULL DEFAULT nextval('enderecos_id_seq'::regclass),
cep integer NOT NULL,
rua character varying COLLATE pg_catalog."default" NOT NULL,
bairro character varying COLLATE pg_catalog."default" NOT NULL,
cidade character varying COLLATE pg_catalog."default" NOT NULL,
estado character varying COLLATE pg_catalog."default",
CONSTRAINT enderecos_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE public.enderecos
OWNER to postgres;
CREATE TABLE public.professores
(
matricula integer NOT NULL,
nome character varying COLLATE pg_catalog."default" NOT NULL,
sobrenome character varying COLLATE pg_catalog."default" NOT NULL,
idade integer NOT NULL,
naturalidade character varying COLLATE pg_catalog."default" NOT NULL,
sexo "char" NOT NULL,
cpf character varying COLLATE pg_catalog."default" NOT NULL,
salario money NOT NULL,
carga_horaria integer NOT NULL,
id_endereco integer NOT NULL,
CONSTRAINT professores_pkey PRIMARY KEY (matricula),
CONSTRAINT id_endereco_fkey FOREIGN KEY (id_endereco)
REFERENCES public.enderecos (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
TABLESPACE pg_default;
ALTER TABLE public.professores
OWNER to postgres;
-- Index: fki_id_endereco_fkey
-- DROP INDEX public.fki_id_endereco_fkey;
CREATE INDEX fki_id_endereco_fkey
ON public.professores USING btree
(id_endereco ASC NULLS LAST)
TABLESPACE pg_default;
CREATE TABLE public.alunos
(
matricula integer NOT NULL,
nome character varying COLLATE pg_catalog."default" NOT NULL,
sobrenome character varying COLLATE pg_catalog."default" NOT NULL,
idade integer NOT NULL,
naturalidade character varying COLLATE pg_catalog."default" NOT NULL,
sexo "char" NOT NULL,
cpf character varying COLLATE pg_catalog."default" NOT NULL,
curso character varying COLLATE pg_catalog."default" NOT NULL,
matriculado boolean NOT NULL,
aprovado boolean NOT NULL,
id_endereco integer NOT NULL,
CONSTRAINT alunos_pkey PRIMARY KEY (matricula),
CONSTRAINT id_endereco_fkey FOREIGN KEY (id_endereco)
REFERENCES public.enderecos (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
TABLESPACE pg_default;
ALTER TABLE public.alunos
OWNER to postgres;
-- Index: fki_id_endereco_alunos_fkey
-- DROP INDEX public.fki_id_endereco_alunos_fkey;
CREATE INDEX fki_id_endereco_alunos_fkey
ON public.alunos USING btree
(id_endereco ASC NULLS LAST)
TABLESPACE pg_default;
CREATE TABLE public.notas
(
id integer NOT NULL DEFAULT nextval('notas_id_seq'::regclass),
valor real NOT NULL,
peso integer NOT NULL,
matricula_aluno integer NOT NULL,
CONSTRAINT notas_pkey PRIMARY KEY (id),
CONSTRAINT matricula_aluno_fkey FOREIGN KEY (matricula_aluno)
REFERENCES public.alunos (matricula) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
TABLESPACE pg_default;
ALTER TABLE public.notas
OWNER to postgres;
-- Index: fki_matricula_aluno_fkey
-- DROP INDEX public.fki_matricula_aluno_fkey;
CREATE INDEX fki_matricula_aluno_fkey
ON public.notas USING btree
(matricula_aluno ASC NULLS LAST)
TABLESPACE pg_default;