MODELO RELACIONAL
Por: ewfewmfkmew • 20/11/2016 • Trabalho acadêmico • 3.483 Palavras (14 Páginas) • 357 Visualizações
TABELA ESCOLA:
-- Table: public."Escola"
-- DROP TABLE public."Escola";
CREATE TABLE public."Escola"
(
codigo character varying(3) COLLATE "default".pg_catalog NOT NULL,
nome character varying(40) COLLATE "default".pg_catalog NOT NULL,
"Professor_dirige" integer NOT NULL DEFAULT nextval('"Escola_dirige_seq"'::regclass),
CONSTRAINT "Escola_pkey" PRIMARY KEY (codigo),
CONSTRAINT "Professor_dirige" FOREIGN KEY ("Professor_dirige")
REFERENCES public."Professor" ("Matricula") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."Escola"
OWNER to postgres;
COMMENT ON COLUMN public."Escola".nome
IS 'Nome da escola';
TABELA TELEFONE_ESCOLA:
-- Table: public."Telefone_escola"
-- DROP TABLE public."Telefone_escola";
CREATE TABLE public."Telefone_escola"
(
"Codigo_Escola" character varying COLLATE "default".pg_catalog NOT NULL,
"Numero_Telefone" numeric,
CONSTRAINT "Telefone_pkey" PRIMARY KEY ("Codigo_Escola"),
CONSTRAINT "Codigo_escola" FOREIGN KEY ("Codigo_Escola")
REFERENCES public."Escola" (codigo) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."Telefone_escola"
OWNER to postgres;
TABELA CURSO:
-- Table: public."Curso"
-- DROP TABLE public."Curso";
CREATE TABLE public."Curso"
(
"Codigo" numeric(3) NOT NULL,
"Nome" character varying(40) COLLATE "default".pg_catalog NOT NULL,
"Descricao" character varying(200) COLLATE "default".pg_catalog,
"Horas_aula" numeric(3) NOT NULL,
"Coordena_professor" integer NOT NULL DEFAULT nextval('curso_coordena_seq'::regclass),
"Administrado_Escola" character varying COLLATE "default".pg_catalog NOT NULL,
CONSTRAINT "Curso_pkey" PRIMARY KEY ("Codigo"),
CONSTRAINT "Administrado_Escola" FOREIGN KEY ("Administrado_Escola")
REFERENCES public."Escola" (codigo) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "Coordena_Professor" FOREIGN KEY ("Coordena_professor")
REFERENCES public."Professor" ("Matricula") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."Curso"
OWNER to postgres;
TABELA DISCIPLINA:
-- Table: public."Disciplina"
-- DROP TABLE public."Disciplina";
CREATE TABLE public."Disciplina"
(
codigo numeric(4) NOT NULL,
nome character varying(40) COLLATE "default".pg_catalog NOT NULL,
horas_aula numeric(1) NOT NULL,
oferecida_escola character varying COLLATE "default".pg_catalog NOT NULL,
CONSTRAINT "Disciplina_pkey" PRIMARY KEY (codigo),
CONSTRAINT oferecida_escola FOREIGN KEY (oferecida_escola)
REFERENCES public."Escola" (codigo) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."Disciplina"
OWNER to postgres;
TABELA TURMA:
-- Table: public."Turma"
-- DROP TABLE public."Turma";
CREATE TABLE public."Turma"
(
id_turma "char" NOT NULL,
codigo character varying(3) COLLATE "default".pg_catalog NOT NULL,
ano numeric(4) NOT NULL,
semestre numeric(1) NOT NULL,
codigo_disciplina numeric(4) NOT NULL,
CONSTRAINT "Turma_pkey" PRIMARY KEY (codigo_disciplina, id_turma),
CONSTRAINT "Turma_id_turma_key" UNIQUE (id_turma),
CONSTRAINT codigo_disciplina FOREIGN KEY (codigo_disciplina)
REFERENCES public."Disciplina" (codigo) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."Turma"
OWNER to postgres;
TABELA SALA:
-- Table: public."Sala"
-- DROP TABLE public."Sala";
CREATE TABLE public."Sala"
(
codigo "char" NOT NULL,
area character varying(2) COLLATE "default".pg_catalog NOT NULL,
bloco character varying(1) COLLATE "default".pg_catalog NOT NULL,
numero numeric(3) NOT NULL,
capacidade numeric(3) NOT NULL,
CONSTRAINT "Sala_pkey" PRIMARY KEY (codigo)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."Sala"
OWNER to postgres;
TABELA HORARIO:
-- Table: public."Horario"
-- DROP TABLE public."Horario";
...