Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

-- Database: Calificaciones

--DROP DATABASE "Calificaciones";

CREATE DATABASE "Calificaciones"


WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'Spanish_Spain.1252'
LC_CTYPE = 'Spanish_Spain.1252'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;

---- Crear Tablas ----

---- Tabla Cursos ----


CREATE TABLE public.cursos(
cod_cur character(10) COLLATE pg_catalog."default" NOT NULL,
curso character(20) COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT pk_cod_cur PRIMARY KEY (cod_cur)
)

TABLESPACE pg_default;

ALTER TABLE public.cursos


OWNER to postgres;

---- Tabla Profesores ----


CREATE TABLE public.profesores(
cod_prof character(10) COLLATE pg_catalog."default" NOT NULL,
contraseña_prof character(20) COLLATE pg_catalog."default" NOT NULL,
nombre character(30) COLLATE pg_catalog."default" NOT NULL,
apellido character(60) COLLATE pg_catalog."default" NOT NULL,
domicilio character(90) COLLATE pg_catalog."default" NOT NULL,
celular character(90) COLLATE pg_catalog."default" NOT NULL,
email character(60) COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT pk_cod_prof PRIMARY KEY(cod_prof)
)

TABLESPACE pg_default;

ALTER TABLE public.profesores


OWNER to postgres;

---- Tabla Materias ----


CREATE TABLE public.materia(
cod_materia character(20) COLLATE pg_catalog."default" NOT NULL,
materia character(30) COLLATE pg_catalog."default" NOT NULL,
curso_cod character(10) COLLATE pg_catalog."default" NOT NULL,
prof_cod character(10) COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT pk_cod_materia PRIMARY KEY(cod_materia),
CONSTRAINT fk_cod_curso FOREIGN KEY(curso_cod)
REFERENCES public.cursos (cod_cur),
CONSTRAINT fk_cod_prof FOREIGN KEY(prof_cod)
REFERENCES public.profesores(cod_prof)
)

TABLESPACE pg_default;
ALTER TABLE public.materia
OWNER to postgres;

---- Tabla Fichas ----


CREATE TABLE public.fichas(
cod_est character(10) COLLATE pg_catalog."default" NOT NULL,
contraseña_est character(20) COLLATE pg_catalog."default" NOT NULL,
nombre character(30) COLLATE pg_catalog."default" NOT NULL,
apellidos character(90) COLLATE pg_catalog."default" NOT NULL,
domicilio character(90) COLLATE pg_catalog."default" NOT NULL,
fecha_nacimiento date,
sexo character(10) COLLATE pg_catalog."default" NOT NULL,
padre character(70) COLLATE pg_catalog."default" NOT NULL,
madre character(70) COLLATE pg_catalog."default" NOT NULL,
encargado character(70) COLLATE pg_catalog."default" NOT NULL,
cod_curso character(8) COLLATE pg_catalog."default" NOT NULL,
fecha_matricula date,
CONSTRAINT pk_cod_est PRIMARY KEY(cod_est),
CONSTRAINT fk_cod_cur FOREIGN KEY(cod_curso)
REFERENCES public.cursos(cod_cur)
)

TABLESPACE pg_default;

ALTER TABLE public.materia


OWNER to postgres;

----Tabla Notas----
CREATE TABLE public.notas(
cod_est character(15) COLLATE pg_catalog."default" NOT NULL,
cod_curs character(8) COLLATE pg_catalog."default" NOT NULL,
cod_mate character(8) COLLATE pg_catalog."default" NOT NULL,
año character(10) COLLATE pg_catalog."default" NOT NULL,
insumo11 float,
insumo12 float,
insumo13 float,
insumo14 float,
pruebSum11 float,
promGen11 float,
insumo21 float,
insumo22 float,
insumo23 float,
insumo24 float,
pruebSum21 float,
promGen21 float,
insumo31 float,
insumo32 float,
insumo33 float,
insumo34 float,
pruebSum31 float,
promGen31 float,
promTot1 float,
exQuim1 float,
notQuim1 float,
insumo41 float,
insumo42 float,
insumo43 float,
insumo44 float,
pruebSum41 float,
promGen41 float,
insumo51 float,
insumo52 float,
insumo53 float,
insumo54 float,
pruebSum51 float,
promGen51 float,
insumo61 float,
insumo62 float,
insumo63 float,
insumo64 float,
pruebSum61 float,
promGen61 float,
promTot2 float,
exQuim2 float,
notQuim2 float,
promFin float,
exRec float,
exRec2 float,
CONSTRAINT fk_cod_est FOREIGN KEY(cod_est)
REFERENCES public.fichas(cod_est),
CONSTRAINT fk_cod_cur FOREIGN KEY(cod_curs)
REFERENCES public.cursos(cod_cur),
CONSTRAINT fk_cod_mat FOREIGN KEY(cod_mate)
REFERENCES public.materia(cod_materia),
PRIMARY KEY(cod_est, cod_curs, cod_mate)
)

TABLESPACE pg_default;

ALTER TABLE public.notas


OWNER to postgres;

You might also like