You are on page 1of 31

IMPLEMENTACIÓN DE LAS BASES DE DATOS

JHON EDINSON LÓPEZ DURÁN


LAYONETH ENRIQUE PAREJA FONSECA

PROFESOR: JAIME OCTAVIO ALBARRACÍN FERREIRA

UNIVERSIDAD INDUSTRIAL DE SANTANDER


FACULTAD DE INGENIERÍA FISICOMECANICAS
INGENIERÍA DE SISTEMAS E INFORMÁTICA
BUCARAMANGA
2017
MER HELADERÍA
DIAGRAMA REFERENCIAL HELADERÍA
MODELO RELACIONAL
CARRITOS

FACTURAS

HELADOS
INCLUYEN POSEE

INGREDIENTES

PROV_TEL_FIJO
PROV_TEL_MOVIL

PROVEE

REQUIERE VENDE
VEN_POSEE

VENDEDORES
-- CONSTRAINT carritos_num_car_check CHECK
-- PostgreSQL database dump (((num_car >= 0) AND (num_car <= 99))),
-- CONSTRAINT carritos_para_car_check CHECK
((((para_car)::text = 'Si'::text) OR ((para_car)::text =
SET statement_timeout = 0; 'No'::text)))
SET lock_timeout = 0; );
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false; ALTER TABLE public.carritos OWNER TO postgres;
SET client_min_messages = warning;
--
-- -- Name: facturas; Type: TABLE; Schema: public;
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: postgres; Tablespace:
Owner: --
--
CREATE TABLE facturas (
CREATE EXTENSION IF NOT EXISTS plpgsql WITH num_fac integer NOT NULL,
SCHEMA pg_catalog; fec_fac date NOT NULL,
pago_fac date NOT NULL,
val_neto_fac integer NOT NULL,
-- val_fle_fac integer NOT NULL,
-- Name: EXTENSION plpgsql; Type: COMMENT; iva_fac integer NOT NULL,
Schema: -; Owner: nit_pro character varying(5) NOT NULL
-- );

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL


procedural language'; ALTER TABLE public.facturas OWNER TO postgres;

--
SET search_path = public, pg_catalog; -- Name: facturas_num_fac_seq; Type: SEQUENCE;
Schema: public; Owner: postgres
SET default_tablespace = ''; --

SET default_with_oids = false; CREATE SEQUENCE facturas_num_fac_seq


START WITH 1
-- INCREMENT BY 1
-- Name: carritos; Type: TABLE; Schema: public; NO MINVALUE
Owner: postgres; Tablespace: NO MAXVALUE
-- CACHE 1;

CREATE TABLE carritos (


num_car smallint NOT NULL, ALTER TABLE public.facturas_num_fac_seq OWNER
cap_car character varying(7) NOT NULL, TO postgres;
pue_uso_car date NOT NULL,
para_car character varying(2) NOT NULL, --
ced_ven character varying(5) NOT NULL, -- Name: facturas_num_fac_seq; Type: SEQUENCE
CONSTRAINT carritos_cap_car_check CHECK OWNED BY; Schema: public; Owner: postgres
((((cap_car)::text = 'Grande'::text) OR --
((cap_car)::text = 'Pequeño'::text))),
ALTER SEQUENCE facturas_num_fac_seq OWNED CACHE 1;
BY facturas.num_fac;

ALTER TABLE public.incluye_num_fac_seq OWNER


-- TO postgres;
-- Name: helados; Type: TABLE; Schema: public;
Owner: postgres; Tablespace: --
-- -- Name: incluye_num_fac_seq; Type: SEQUENCE
OWNED BY; Schema: public; Owner: postgres
CREATE TABLE helados ( --
cod_hel integer NOT NULL,
desc_sab_hel character varying(10) NOT NULL, ALTER SEQUENCE incluye_num_fac_seq OWNED BY
pres_hel character varying NOT NULL, incluye.num_fac;
exist_hel integer NOT NULL,
gr_hel integer NOT NULL,
prec_hel integer NOT NULL, --
CONSTRAINT helados_pres_hel_check CHECK -- Name: ingredientes; Type: TABLE; Schema:
(((((pres_hel)::text = 'copa'::text) OR public; Owner: postgres; Tablespace:
((pres_hel)::text = 'cono'::text)) OR ((pres_hel)::text --
= 'galleta'::text)))
); CREATE TABLE ingredientes (
cod_ing character varying(3) NOT NULL,
nom_ing character varying(12) NOT NULL,
ALTER TABLE public.helados OWNER TO postgres; exist_hel integer NOT NULL,
medida_hel character varying(10) NOT NULL,
-- ult_com_ing date NOT NULL,
-- Name: incluye; Type: TABLE; Schema: public; val_ult_com_ing integer NOT NULL
Owner: postgres; Tablespace: );
--

CREATE TABLE incluye ( ALTER TABLE public.ingredientes OWNER TO


num_fac integer NOT NULL, postgres;
cod_ing character varying(3) NOT NULL,
cant_ing integer NOT NULL --
); -- Name: posee; Type: TABLE; Schema: public;
Owner: postgres; Tablespace:
--
ALTER TABLE public.incluye OWNER TO postgres;
CREATE TABLE posee (
-- num_car smallint NOT NULL,
-- Name: incluye_num_fac_seq; Type: SEQUENCE; cod_hel integer NOT NULL
Schema: public; Owner: postgres );
--

CREATE SEQUENCE incluye_num_fac_seq ALTER TABLE public.posee OWNER TO postgres;


START WITH 1
INCREMENT BY 1 --
NO MINVALUE -- Name: prov_tel_fijo; Type: TABLE; Schema:
NO MAXVALUE public; Owner: postgres; Tablespace:
--
ALTER TABLE public.proveedores OWNER TO
CREATE TABLE prov_tel_fijo ( postgres;
nit_pro character varying(5) NOT NULL,
tel_fijo character varying(7) NOT NULL --
); -- Name: requiere; Type: TABLE; Schema: public;
Owner: postgres; Tablespace:
--
ALTER TABLE public.prov_tel_fijo OWNER TO
postgres; CREATE TABLE requiere (
cod_hel integer NOT NULL,
-- cod_ing character varying(3) NOT NULL
-- Name: prov_tel_movil; Type: TABLE; Schema: );
public; Owner: postgres; Tablespace:
--
ALTER TABLE public.requiere OWNER TO postgres;
CREATE TABLE prov_tel_movil (
nit_pro character varying(5) NOT NULL, --
tel_movil character varying(10) NOT NULL -- Name: ven_posee; Type: TABLE; Schema: public;
); Owner: postgres; Tablespace:
--

ALTER TABLE public.prov_tel_movil OWNER TO CREATE TABLE ven_posee (


postgres; ced_ven character varying(5) NOT NULL,
num_car smallint NOT NULL,
-- cod_hel integer NOT NULL,
-- Name: provee; Type: TABLE; Schema: public; cant_hel integer NOT NULL
Owner: postgres; Tablespace: );
--

CREATE TABLE provee ( ALTER TABLE public.ven_posee OWNER TO


nit_pro character varying(5) NOT NULL, postgres;
cod_ing character varying(3) NOT NULL
); --
-- Name: vende; Type: TABLE; Schema: public;
Owner: postgres; Tablespace:
ALTER TABLE public.provee OWNER TO postgres; --

-- CREATE TABLE vende (


-- Name: proveedores; Type: TABLE; Schema: ced_ven character varying(5) NOT NULL,
public; Owner: postgres; Tablespace: cod_hel integer NOT NULL
-- );

CREATE TABLE proveedores (


nit_pro character varying(5) NOT NULL, ALTER TABLE public.vende OWNER TO postgres;
nom_pro character varying(20) NOT NULL,
email_pro character varying(30) NOT NULL --
); -- Name: vendedores; Type: TABLE; Schema: public;
Owner: postgres; Tablespace:
-- --
-- Data for Name: facturas; Type: TABLE DATA;
CREATE TABLE vendedores ( Schema: public; Owner: postgres
ced_ven character varying(5) NOT NULL, --
nom_ven character varying NOT NULL,
dir_ven character varying(30) NOT NULL, COPY facturas (num_fac, fec_fac, pago_fac,
wpp_ven character varying(10) NOT NULL, val_neto_fac, val_fle_fac, iva_fac, nit_pro) FROM
cel_ven character varying(10) NOT NULL stdin;
); 1 2017-05-10 2017-05-10 42700 3500
6000 56643
2 2017-04-15 2017-04-15 98350 5000
ALTER TABLE public.vendedores OWNER TO 5300 19087
postgres; 3 2017-06-19 2017-06-26 115000
4800 5100 11720
-- 4 2017-02-28 2017-02-28 74200 4200
-- Name: num_fac; Type: DEFAULT; Schema: public; 5550 56643
Owner: postgres 5 2017-07-01 2017-07-07 71900 4200
-- 7420 19087
\.
ALTER TABLE ONLY facturas ALTER COLUMN
num_fac SET DEFAULT
nextval('facturas_num_fac_seq'::regclass); --
-- Name: facturas_num_fac_seq; Type: SEQUENCE
SET; Schema: public; Owner: postgres
-- --
-- Name: num_fac; Type: DEFAULT; Schema: public;
Owner: postgres SELECT pg_catalog.setval('facturas_num_fac_seq',
-- 1, false);

ALTER TABLE ONLY incluye ALTER COLUMN


num_fac SET DEFAULT --
nextval('incluye_num_fac_seq'::regclass); -- Data for Name: helados; Type: TABLE DATA;
Schema: public; Owner: postgres
--
--
-- Data for Name: carritos; Type: TABLE DATA; COPY helados (cod_hel, desc_sab_hel, pres_hel,
Schema: public; Owner: postgres exist_hel, gr_hel, prec_hel) FROM stdin;
-- 78632 Vainilla cono 78 70 2500
14341 Chocolate cono 56 70 2000
COPY carritos (num_car, cap_car, pue_uso_car, 78065 Mora copa 89 110 3000
para_car, ced_ven) FROM stdin; 28564 Arequipe galleta 104 50 2000
4 Grande 2015-05-01 Si 98728 10098 Chocolate galleta 93 60 2200
16 Grande 2016-07-01 Si 67231 \.
35 Pequeño 2015-11-15 No 25813
78 Grande 2016-08-01 Si 98728
92 Pequeño 2017-02-01 No 25813 --
\. -- Data for Name: incluye; Type: TABLE DATA;
Schema: public; Owner: postgres
--
92 28564
COPY incluye (num_fac, cod_ing, cant_ing) FROM \.
stdin;
1 001 12
1 045 5 --
2 020 10 -- Data for Name: prov_tel_fijo; Type: TABLE DATA;
2 010 15 Schema: public; Owner: postgres
4 020 20 --
\.
COPY prov_tel_fijo (nit_pro, tel_fijo) FROM stdin;
11720 6915187
-- 11720 6832177
-- Name: incluye_num_fac_seq; Type: SEQUENCE 19087 6919088
SET; Schema: public; Owner: postgres 78992 6321167
-- 56643 6464531
\.
SELECT pg_catalog.setval('incluye_num_fac_seq', 1,
false);
--
-- Data for Name: prov_tel_movil; Type: TABLE
-- DATA; Schema: public; Owner: postgres
-- Data for Name: ingredientes; Type: TABLE DATA; --
Schema: public; Owner: postgres
-- COPY prov_tel_movil (nit_pro, tel_movil) FROM
stdin;
COPY ingredientes (cod_ing, nom_ing, exist_hel, 11720 3127890098
medida_hel, ult_com_ing, val_ult_com_ing) FROM 11720 3159083311
stdin; 19087 3133487901
001 Leche 60 Litros 2017-07-15 50000 78992 3122456710
007 Azúcar 30 Kilogramos 2017-05-20 56643 3116755908
25000 \.
020 Miel 20 Litros 2017-05-28 18000
045 Mora 25 Kilogramos 2017-06-05
15000 --
010 Sal 20 Kilogramos 2017-07-10 -- Data for Name: provee; Type: TABLE DATA;
20000 Schema: public; Owner: postgres
\. --

COPY provee (nit_pro, cod_ing) FROM stdin;


-- 78992 001
-- Data for Name: posee; Type: TABLE DATA; 78992 007
Schema: public; Owner: postgres 19087 020
-- 19087 045
56300 010
COPY posee (num_car, cod_hel) FROM stdin; \.
4 14341
4 78632
4 10098 --
35 14341
-- Data for Name: proveedores; Type: TABLE DATA; COPY vende (ced_ven, cod_hel) FROM stdin;
Schema: public; Owner: postgres 98728 14341
-- 25813 78632
25813 10098
COPY proveedores (nit_pro, nom_pro, email_pro) 23424 14341
FROM stdin; 67231 28564
78992 Rodrigo Castro rcastro@hotmail.com \.
56643 Ángela Casas angcasas@gmail.com
19087 Rafael Santos santosrafael@gmail.com
11720 Héctor Ramírez --
hramirez1@hotmai.com -- Data for Name: vendedores; Type: TABLE DATA;
56300 Gabriela Contreras gabrielac@gmail.com Schema: public; Owner: postgres
\. --

COPY vendedores (ced_ven, nom_ven, dir_ven,


-- wpp_ven, cel_ven) FROM stdin;
-- Data for Name: requiere; Type: TABLE DATA; 23424 Oscar Rangel Calle 21 # 45-31
Schema: public; Owner: postgres 3125829087 3125829087
-- 98728 Omar Rivera Carrera 21 # 11-05
3156711234 3156711234
COPY requiere (cod_hel, cod_ing) FROM stdin; 25813 Luis Guerrero Calle 17 # 20-13
78632 007 3149087761 3149087761
14341 020 98166 Marta Pinto Calle 21 # 14-15
78065 045 3155660901 3155660901
28564 010 67231 Javier Oñate Carrera 7 # 31-21
78632 001 3125678944 3125678944
\. \.

-- --
-- Data for Name: ven_posee; Type: TABLE DATA; -- Name: car_pkey; Type: CONSTRAINT; Schema:
Schema: public; Owner: postgres public; Owner: postgres; Tablespace:
-- --

COPY ven_posee (ced_ven, num_car, cod_hel, ALTER TABLE ONLY carritos


cant_hel) FROM stdin; ADD CONSTRAINT car_pkey PRIMARY KEY
67231 4 28564 15 (num_car);
67231 4 14341 25
25813 78 28564 20
67231 35 10098 15 --
98166 16 14341 20 -- Name: fac_pkey; Type: CONSTRAINT; Schema:
\. public; Owner: postgres; Tablespace:
--

-- ALTER TABLE ONLY facturas


-- Data for Name: vende; Type: TABLE DATA; ADD CONSTRAINT fac_pkey PRIMARY KEY
Schema: public; Owner: postgres (num_fac);
--
--
-- Name: hel_pkey; Type: CONSTRAINT; Schema: --
public; Owner: postgres; Tablespace: -- Name: pro_movil_pkey; Type: CONSTRAINT;
-- Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY helados
ADD CONSTRAINT hel_pkey PRIMARY KEY ALTER TABLE ONLY prov_tel_movil
(cod_hel); ADD CONSTRAINT pro_movil_pkey PRIMARY KEY
(nit_pro, tel_movil);

--
-- Name: inc_pkey; Type: CONSTRAINT; Schema: --
public; Owner: postgres; Tablespace: -- Name: pro_pkey; Type: CONSTRAINT; Schema:
-- public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY incluye
ADD CONSTRAINT inc_pkey PRIMARY KEY ALTER TABLE ONLY proveedores
(num_fac, cod_ing); ADD CONSTRAINT pro_pkey PRIMARY KEY
(nit_pro);

--
-- Name: ing_pkey; Type: CONSTRAINT; Schema: --
public; Owner: postgres; Tablespace: -- Name: provee_pkey; Type: CONSTRAINT;
-- Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY ingredientes
ADD CONSTRAINT ing_pkey PRIMARY KEY ALTER TABLE ONLY provee
(cod_ing); ADD CONSTRAINT provee_pkey PRIMARY KEY
(nit_pro, cod_ing);

--
-- Name: posee_pkey; Type: CONSTRAINT; Schema: --
public; Owner: postgres; Tablespace: -- Name: req_pkey; Type: CONSTRAINT; Schema:
-- public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY posee
ADD CONSTRAINT posee_pkey PRIMARY KEY ALTER TABLE ONLY requiere
(num_car, cod_hel); ADD CONSTRAINT req_pkey PRIMARY KEY
(cod_hel, cod_ing);

--
-- Name: pro_fijo_pkey; Type: CONSTRAINT; --
Schema: public; Owner: postgres; Tablespace: -- Name: ven_pkey; Type: CONSTRAINT; Schema:
-- public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prov_tel_fijo
ADD CONSTRAINT pro_fijo_pkey PRIMARY KEY ALTER TABLE ONLY vendedores
(nit_pro, tel_fijo); ADD CONSTRAINT ven_pkey PRIMARY KEY
(ced_ven);
ADD CONSTRAINT inc_fkey1 FOREIGN KEY
(num_fac) REFERENCES facturas(num_fac);
--
-- Name: vende_pkey; Type: CONSTRAINT; Schema:
public; Owner: postgres; Tablespace: --
-- -- Name: inc_fkey2; Type: FK CONSTRAINT;
Schema: public; Owner: postgres
ALTER TABLE ONLY vende --
ADD CONSTRAINT vende_pkey PRIMARY KEY
(ced_ven, cod_hel); ALTER TABLE ONLY incluye
ADD CONSTRAINT inc_fkey2 FOREIGN KEY
(cod_ing) REFERENCES ingredientes(cod_ing);
--
-- Name: vp_pkey; Type: CONSTRAINT; Schema:
public; Owner: postgres; Tablespace: --
-- -- Name: posee_fkey1; Type: FK CONSTRAINT;
Schema: public; Owner: postgres
ALTER TABLE ONLY ven_posee --
ADD CONSTRAINT vp_pkey PRIMARY KEY
(ced_ven, num_car, cod_hel); ALTER TABLE ONLY posee
ADD CONSTRAINT posee_fkey1 FOREIGN KEY
(num_car) REFERENCES carritos(num_car);
--
-- Name: car_fkey; Type: FK CONSTRAINT; Schema:
public; Owner: postgres --
-- -- Name: posee_fkey2; Type: FK CONSTRAINT;
Schema: public; Owner: postgres
ALTER TABLE ONLY carritos --
ADD CONSTRAINT car_fkey FOREIGN KEY
(ced_ven) REFERENCES vendedores(ced_ven); ALTER TABLE ONLY posee
ADD CONSTRAINT posee_fkey2 FOREIGN KEY
(cod_hel) REFERENCES helados(cod_hel);
--
-- Name: fac_fkey; Type: FK CONSTRAINT; Schema:
public; Owner: postgres --
-- -- Name: provee_fkey1; Type: FK CONSTRAINT;
Schema: public; Owner: postgres
ALTER TABLE ONLY facturas --
ADD CONSTRAINT fac_fkey FOREIGN KEY
(nit_pro) REFERENCES proveedores(nit_pro); ALTER TABLE ONLY provee
ADD CONSTRAINT provee_fkey1 FOREIGN KEY
(nit_pro) REFERENCES proveedores(nit_pro);
--
-- Name: inc_fkey1; Type: FK CONSTRAINT;
Schema: public; Owner: postgres --
-- -- Name: provee_fkey2; Type: FK CONSTRAINT;
Schema: public; Owner: postgres
ALTER TABLE ONLY incluye --
ALTER TABLE ONLY provee --
ADD CONSTRAINT provee_fkey2 FOREIGN KEY
(cod_ing) REFERENCES ingredientes(cod_ing); ALTER TABLE ONLY ven_posee
ADD CONSTRAINT vp_fkey1 FOREIGN KEY
(ced_ven) REFERENCES vendedores(ced_ven);
--
-- Name: req_fkey1; Type: FK CONSTRAINT;
Schema: public; Owner: postgres --
-- -- Name: vp_fkey2; Type: FK CONSTRAINT; Schema:
public; Owner: postgres
ALTER TABLE ONLY requiere --
ADD CONSTRAINT req_fkey1 FOREIGN KEY
(cod_hel) REFERENCES helados(cod_hel); ALTER TABLE ONLY ven_posee
ADD CONSTRAINT vp_fkey2 FOREIGN KEY
(num_car) REFERENCES carritos(num_car);
--
-- Name: req_fkey2; Type: FK CONSTRAINT;
Schema: public; Owner: postgres --
-- -- Name: vp_fkey3; Type: FK CONSTRAINT; Schema:
public; Owner: postgres
ALTER TABLE ONLY requiere --
ADD CONSTRAINT req_fkey2 FOREIGN KEY
(cod_ing) REFERENCES ingredientes(cod_ing); ALTER TABLE ONLY ven_posee
ADD CONSTRAINT vp_fkey3 FOREIGN KEY
(cod_hel) REFERENCES helados(cod_hel);
--
-- Name: vende_fkey1; Type: FK CONSTRAINT;
Schema: public; Owner: postgres --
-- -- Name: public; Type: ACL; Schema: -; Owner:
postgres
ALTER TABLE ONLY vende --
ADD CONSTRAINT vende_fkey1 FOREIGN KEY
(ced_ven) REFERENCES vendedores(ced_ven); REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
-- GRANT ALL ON SCHEMA public TO PUBLIC;
-- Name: vende_fkey2; Type: FK CONSTRAINT;
Schema: public; Owner: postgres
-- --
-- PostgreSQL database dump complete
ALTER TABLE ONLY vende --
ADD CONSTRAINT vende_fkey2 FOREIGN KEY
(cod_hel) REFERENCES helados(cod_hel);

--
-- Name: vp_fkey1; Type: FK CONSTRAINT; Schema:
public; Owner: postgres
FOGASA

MER FOGASA
DIAGRAMA REFERENCIAL
MODELO RELACIONAL
ANIMALES

CONTRATOS

CONTROL

CRIA
DEPOSITARIOS

FUNCIONARIOS

TELEFONO_DEPOSI
VACUNA

VACUNADORES

VETERINARIOS
--
-- PostgreSQL database dump ALTER TABLE public.animales OWNER TO postgres;
--
--
SET statement_timeout = 0; -- Name: contratos; Type: TABLE; Schema: public;
SET lock_timeout = 0; Owner: postgres; Tablespace:
SET client_encoding = 'UTF8'; --
SET standard_conforming_strings = on;
SET check_function_bodies = false; CREATE TABLE contratos (
SET client_min_messages = warning; num_cto integer NOT NULL,
cant_cab_cto character varying(7) NOT NULL,
-- cant_kg_cto character varying(10) NOT NULL,
-- Name: plpgsql; Type: EXTENSION; Schema: -; ini_cto date NOT NULL,
Owner: valor_ini_cto character varying(10) NOT NULL,
-- id_dep character varying(3) NOT NULL
);
CREATE EXTENSION IF NOT EXISTS plpgsql WITH
SCHEMA pg_catalog;
ALTER TABLE public.contratos OWNER TO postgres;

-- --
-- Name: EXTENSION plpgsql; Type: COMMENT; -- Name: contratos_num_cto_seq; Type:
Schema: -; Owner: SEQUENCE; Schema: public; Owner: postgres
-- --

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL CREATE SEQUENCE contratos_num_cto_seq


procedural language'; START WITH 1
INCREMENT BY 1
NO MINVALUE
SET search_path = public, pg_catalog; NO MAXVALUE
CACHE 1;
SET default_tablespace = '';

SET default_with_oids = false; ALTER TABLE public.contratos_num_cto_seq


OWNER TO postgres;
--
-- Name: animales; Type: TABLE; Schema: public; --
Owner: postgres; Tablespace: -- Name: contratos_num_cto_seq; Type:
-- SEQUENCE OWNED BY; Schema: public; Owner:
postgres
CREATE TABLE animales ( --
nom_ani character varying(10) NOT NULL,
num_cab_ani character varying(7) NOT NULL, ALTER SEQUENCE contratos_num_cto_seq OWNED
kg_hato_ani character varying(10) NOT NULL, BY contratos.num_cto;
muerte_ani character varying(3),
num_cto integer NOT NULL,
ini_cto date NOT NULL --
); -- Name: control; Type: TABLE; Schema: public;
Owner: postgres; Tablespace:
-- );

CREATE TABLE control (


ced_veter character varying(3) NOT NULL, ALTER TABLE public.depositarios OWNER TO
ced_vcdor character varying(3) NOT NULL, postgres;
num_cto integer NOT NULL,
ini_cto date NOT NULL SET default_with_oids = true;
);
--
-- Name: funcionarios; Type: TABLE; Schema:
ALTER TABLE public.control OWNER TO postgres; public; Owner: postgres; Tablespace:
--
--
-- Name: cria; Type: TABLE; Schema: public; Owner: CREATE TABLE funcionarios (
postgres; Tablespace: ced_fun integer NOT NULL,
-- nom_fun character varying(20) NOT NULL,
dir_fun character varying(30) NOT NULL,
CREATE TABLE cria ( email_fun character varying(30) NOT NULL,
num_cto integer NOT NULL, cel_fun character varying(10) NOT NULL
ini_cto date NOT NULL, );
nacim_cria date NOT NULL
);
ALTER TABLE public.funcionarios OWNER TO
postgres;
ALTER TABLE public.cria OWNER TO postgres;
SET default_with_oids = false;
--
-- Name: depo_telef; Type: TABLE; Schema: public; --
Owner: postgres; Tablespace: -- Name: vacuna; Type: TABLE; Schema: public;
-- Owner: postgres; Tablespace:
--
CREATE TABLE depo_telef (
id_dep character varying(3) NOT NULL, CREATE TABLE vacuna (
telef_dep character varying(10) NOT NULL ced_vcdor integer NOT NULL,
); num_cto integer NOT NULL,
ini_cto date NOT NULL,
fe_pr_vac date NOT NULL,
ALTER TABLE public.depo_telef OWNER TO fe_re_vac date NOT NULL,
postgres; perio_vac character varying(20) NOT NULL,
dosis_vac character varying(10) NOT NULL,
-- enf_vac character varying(15) NOT NULL,
-- Name: depositarios; Type: TABLE; Schema: reg_obj_vac character varying(15) NOT NULL
public; Owner: postgres; Tablespace: );
--

CREATE TABLE depositarios ( ALTER TABLE public.vacuna OWNER TO postgres;


id_dep character varying(3) NOT NULL,
nom_dep character varying(20) NOT NULL, SET default_with_oids = true;
valor_acum_dep character varying(10) NOT NULL
-- Novilla 35 3500 1 4 2016-06-01
-- Name: vacunadores; Type: TABLE; Schema: Toro 10 2000 0 3 2016-10-01
public; Owner: postgres; Tablespace: Caballo 20 3000 2 5 2016-
-- 05-01
\.
CREATE TABLE vacunadores (
lic_vac character varying(10) NOT NULL
) --
INHERITS (funcionarios); -- Data for Name: contratos; Type: TABLE DATA;
Schema: public; Owner: postgres
--
ALTER TABLE public.vacunadores OWNER TO
postgres; COPY contratos (num_cto, cant_cab_cto,
cant_kg_cto, ini_cto, valor_ini_cto, id_dep) FROM
-- stdin;
-- Name: veterinarios; Type: TABLE; Schema: public; 1 100 900000 2016-03-01
Owner: postgres; Tablespace: 5000000 379
-- 2 80 950000 2017-01-01
3000000 763
CREATE TABLE veterinarios ( 3 90 110000 2016-10-01
tarj_pro_vet character varying(10) NOT NULL 3800000 379
) 4 130 150000 2016-06-01
INHERITS (funcionarios); 7200000 109
5 100 1050000 2016-05-01
4900000 348
ALTER TABLE public.veterinarios OWNER TO \.
postgres;

-- --
-- Name: num_cto; Type: DEFAULT; Schema: public; -- Name: contratos_num_cto_seq; Type:
Owner: postgres SEQUENCE SET; Schema: public; Owner: postgres
-- --

ALTER TABLE ONLY contratos ALTER COLUMN SELECT


num_cto SET DEFAULT pg_catalog.setval('contratos_num_cto_seq', 1,
nextval('contratos_num_cto_seq'::regclass); false);

-- --
-- Data for Name: animales; Type: TABLE DATA; -- Data for Name: control; Type: TABLE DATA;
Schema: public; Owner: postgres Schema: public; Owner: postgres
-- --

COPY animales (nom_ani, num_cab_ani, COPY control (ced_veter, ced_vcdor, num_cto,


kg_hato_ani, muerte_ani, num_cto, ini_cto) FROM ini_cto) FROM stdin;
stdin; 653 864 2 2017-01-01
Vaca 20 2500 3 2 2017-01-01 280 864 4 2016-06-01
Ternero 50 3000 0 4 2016- 181 904 3 2016-10-01
06-01 653 550 5 2016-05-01
181 550 1 2016-03-01 -- Data for Name: funcionarios; Type: TABLE DATA;
\. Schema: public; Owner: postgres
--

-- COPY funcionarios (ced_fun, nom_fun, dir_fun,


-- Data for Name: cria; Type: TABLE DATA; Schema: email_fun, cel_fun) FROM stdin;
public; Owner: postgres 181 Jorge Rojas Calle 10 # 20-30
-- jrojas@gmail.com 3125780954
653 Martin Morales Calle 15 # 20-15
COPY cria (num_cto, ini_cto, nacim_cria) FROM martinm1@hotmail.com 3115200987
stdin; 864 Fernando Bautista Carrera 7 # 11-05
1 2016-03-01 2016-03-05 fbautista@hotmail.com 3147898121
2 2017-01-01 2017-01-10 904 Sandra Pereira Carrera 21 # 10-30
3 2016-10-01 2016-10-01 sandrap11@gmail.com 3133599065
4 2016-06-01 2016-06-28 287 Pablo Camacho Calle 17 # 16-26
5 2016-05-01 2017-05-11 camachopb@gmail.com 3124679801
\. 550 Edgar Mendez Carrera 12 # 32-11
edgarmdz@hotmail.com 3156890965
487 Carolina Diaz Carrera 20 # 23-04
-- carodiaz@hotmail.com 3138960095
-- Data for Name: depo_telef; Type: TABLE DATA; 269 Marta Garcia Carrera 17 # 13-12
Schema: public; Owner: postgres martag12@gmail.com 3156118754
-- 280 Jorge Santana Calle 34 # 11-56
santjorge@hotmail.com 3118905632
COPY depo_telef (id_dep, telef_dep) FROM stdin; 167 Antonio Suarez Carrera 27 # 27-51
348 3126789019 ansuarez60@gmail.com 3117655411
379 3133477123 \.
379 3156901233
763 3110987126
763 3129772397 --
\. -- Data for Name: vacuna; Type: TABLE DATA;
Schema: public; Owner: postgres
--
--
-- Data for Name: depositarios; Type: TABLE DATA; COPY vacuna (ced_vcdor, num_cto, ini_cto,
Schema: public; Owner: postgres fe_pr_vac, fe_re_vac, perio_vac, dosis_vac,
-- enf_vac, reg_obj_vac) FROM stdin;
181 3 2016-10-01 2016-11-10 2016-
COPY depositarios (id_dep, nom_dep, 11-10 1 3 Tuberculosis Guanentá
valor_acum_dep) FROM stdin; 653 2 2017-01-01 2017-02-15 2017-
379 Arturo Bueno 75000000 02-20 6 1 Tuberculosis Soto
348 Patricia Franco 10000000 904 3 2016-10-01 2016-10-20 2016-
864 Hernando Pimiento 20000000 10-30 12 3 Fiebre aftosa Guanentá
763 Claudia Forero 37000000 181 5 2017-05-01 2017-06-01 2017-
109 Jairo Niño 45800000 06-01 6 5 Fiebre aftosa Vélez
\. 904 1 2016-10-01 2016-05-01 2016-
05-15 4 3 Tuberculosis Mares
\.
--
181 Jorge Rojas Calle 10 # 20-30
-- jrojas@gmail.com 3125780954
-- Data for Name: vacunadores; Type: TABLE DATA; 7653109
Schema: public; Owner: postgres 653 Martin Morales Calle 15 # 20-15
-- martinm1@hotmail.com 3115200987
1287539
COPY vacunadores (ced_fun, nom_fun, dir_fun, 864 Fernando Bautista Carrera 7 # 11-05
email_fun, cel_fun, lic_vac) FROM stdin; fbautista@hotmail.com 3147898121
550 Edgar Mendez Carrera 12 # 32-11 9678238
edgarmdz@hotmail.com 3156890965 904 Sandra Pereira Carrera 21 # 10-30
10958782 sandrap11@gmail.com 3133599065
487 Carolina Diaz Carrera 20 # 23-04 1986401
carodiaz@hotmail.com 3138960095 287 Pablo Camacho Calle 17 # 16-26
18309868 camachopb@gmail.com 3124679801
269 Marta Garcia Carrera 17 # 13-12 8927611
martag12@gmail.com 3156118754 \.
25497601
280 Jorge Santana Calle 34 # 11-56
santjorge@hotmail.com 3118905632 --
48808811 -- Name: ani_pkey; Type: CONSTRAINT; Schema:
167 Antonio Suarez Carrera 27 # 27-51 public; Owner: postgres; Tablespace:
ansuarez60@gmail.com 3117655411 --
90786587
\. ALTER TABLE ONLY animales
ADD CONSTRAINT ani_pkey PRIMARY KEY
(nom_ani, num_cto, ini_cto);
--
-- Data for Name: veterinarios; Type: TABLE DATA;
Schema: public; Owner: postgres --
-- -- Name: cria_pkey; Type: CONSTRAINT; Schema:
public; Owner: postgres; Tablespace:
COPY veterinarios (ced_fun, nom_fun, dir_fun, --
email_fun, cel_fun, tarj_pro_vet) FROM stdin;
181 Jorge Rojas Calle 10 # 20-30 ALTER TABLE ONLY cria
jrojas@gmail.com 3125780954 ADD CONSTRAINT cria_pkey PRIMARY KEY
7653109 (num_cto, ini_cto);
653 Martin Morales Calle 15 # 20-15
martinm1@hotmail.com 3115200987
1287539 --
864 Fernando Bautista Carrera 7 # 11-05 -- Name: cto_pkey; Type: CONSTRAINT; Schema:
fbautista@hotmail.com 3147898121 public; Owner: postgres; Tablespace:
9678238 --
904 Sandra Pereira Carrera 21 # 10-30
sandrap11@gmail.com 3133599065 ALTER TABLE ONLY contratos
1986401 ADD CONSTRAINT cto_pkey PRIMARY KEY
287 Pablo Camacho Calle 17 # 16-26 (num_cto, ini_cto);
camachopb@gmail.com 3124679801
8927611
--
-- Name: ctrl_pkey; Type: CONSTRAINT; Schema: --
public; Owner: postgres; Tablespace: -- Name: animales_num_cto_fkey; Type: FK
-- CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY control
ADD CONSTRAINT ctrl_pkey PRIMARY KEY ALTER TABLE ONLY animales
(ced_veter, ced_vcdor, num_cto, ini_cto); ADD CONSTRAINT animales_num_cto_fkey
FOREIGN KEY (num_cto, ini_cto) REFERENCES
contratos(num_cto, ini_cto) ON UPDATE CASCADE
-- ON DELETE CASCADE;
-- Name: dep_pkey; Type: CONSTRAINT; Schema:
public; Owner: postgres; Tablespace:
-- --
-- Name: cria_fkey; Type: FK CONSTRAINT; Schema:
ALTER TABLE ONLY depositarios public; Owner: postgres
ADD CONSTRAINT dep_pkey PRIMARY KEY --
(id_dep);
ALTER TABLE ONLY cria
ADD CONSTRAINT cria_fkey FOREIGN KEY
-- (num_cto, ini_cto) REFERENCES
-- Name: dt_pkey; Type: CONSTRAINT; Schema: contratos(num_cto, ini_cto);
public; Owner: postgres; Tablespace:
--
--
ALTER TABLE ONLY depo_telef -- Name: cto_fkey; Type: FK CONSTRAINT; Schema:
ADD CONSTRAINT dt_pkey PRIMARY KEY public; Owner: postgres
(id_dep, telef_dep); --

ALTER TABLE ONLY contratos


-- ADD CONSTRAINT cto_fkey FOREIGN KEY
-- Name: funcionarios_pkey; Type: CONSTRAINT; (id_dep) REFERENCES depositarios(id_dep);
Schema: public; Owner: postgres; Tablespace:
--
--
ALTER TABLE ONLY funcionarios -- Name: ctrl_fkey1; Type: FK CONSTRAINT;
ADD CONSTRAINT funcionarios_pkey PRIMARY Schema: public; Owner: postgres
KEY (ced_fun); --

ALTER TABLE ONLY control


-- ADD CONSTRAINT ctrl_fkey1 FOREIGN KEY
-- Name: vac_pkey; Type: CONSTRAINT; Schema: (num_cto, ini_cto) REFERENCES
public; Owner: postgres; Tablespace: contratos(num_cto, ini_cto);
--

ALTER TABLE ONLY vacuna --


ADD CONSTRAINT vac_pkey PRIMARY KEY -- Name: dt_fkey; Type: FK CONSTRAINT; Schema:
(ced_vcdor, num_cto, ini_cto); public; Owner: postgres
--
ALTER TABLE ONLY depo_telef
ADD CONSTRAINT dt_fkey FOREIGN KEY (id_dep)
REFERENCES depositarios(id_dep);

--
-- Name: public; Type: ACL; Schema: -; Owner:
postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;


REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;

--
-- PostgreSQL database dump complete
--

You might also like