--
-- PostgreSQL database dump
--

-- Dumped from database version 15.1
-- Dumped by pg_dump version 16.3

-- Started on 2024-08-16 17:00:40

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 216 (class 1259 OID 26184)
-- Name: consultas; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.consultas (
    cpconsulta integer NOT NULL,
    cemedico integer,
    dtconsulta date,
    hrconsulta time without time zone,
    dtcadconsulta date,
    cepaciente integer
);


ALTER TABLE public.consultas OWNER TO postgres;

--
-- TOC entry 215 (class 1259 OID 26169)
-- Name: especmedicas; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.especmedicas (
    cpespecmedica smallint NOT NULL,
    txnomeespecmedica character varying(90) NOT NULL,
    dtcadespecmedica date NOT NULL
);


ALTER TABLE public.especmedicas OWNER TO postgres;

--
-- TOC entry 3345 (class 0 OID 0)
-- Dependencies: 215
-- Name: TABLE especmedicas; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.especmedicas IS 'Cadastro das Especialidades Médicas';


--
-- TOC entry 214 (class 1259 OID 26164)
-- Name: medicos; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.medicos (
    cpmedico smallint NOT NULL,
    txnomemedico character varying(250) NOT NULL,
    ceespecmedica smallint,
    dtcadmedico date
);


ALTER TABLE public.medicos OWNER TO postgres;

--
-- TOC entry 3346 (class 0 OID 0)
-- Dependencies: 214
-- Name: TABLE medicos; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.medicos IS 'Cadastro dos médicos de uma cidade (que participam nas Unidades Básicas de Saúde)';


--
-- TOC entry 217 (class 1259 OID 26194)
-- Name: pacientes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.pacientes (
    cppaciente integer NOT NULL,
    txnomepaciente character varying(250),
    dtnascpaciente date,
    dtcadpaciente date
);


ALTER TABLE public.pacientes OWNER TO postgres;

--
-- TOC entry 3347 (class 0 OID 0)
-- Dependencies: 217
-- Name: TABLE pacientes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.pacientes IS 'Cadastro de pacientes de uma rede municipal de saúde.';


--
-- TOC entry 3338 (class 0 OID 26184)
-- Dependencies: 216
-- Data for Name: consultas; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 3337 (class 0 OID 26169)
-- Dependencies: 215
-- Data for Name: especmedicas; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 3336 (class 0 OID 26164)
-- Dependencies: 214
-- Data for Name: medicos; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 3339 (class 0 OID 26194)
-- Dependencies: 217
-- Data for Name: pacientes; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.pacientes VALUES (1, 'José Felisberto de Athaide', '1998-04-15', '2024-08-16');
INSERT INTO public.pacientes VALUES (2, 'Ana Maria De Alburque Lins', '1998-10-05', '2024-08-16');
INSERT INTO public.pacientes VALUES (4, 'Ana Maria De Alburque Lins', '1998-10-05', '2024-08-16');
INSERT INTO public.pacientes VALUES (3, 'José Felisberto de Athaide', '1997-03-10', '2024-08-16');


--
-- TOC entry 3189 (class 2606 OID 26188)
-- Name: consultas pkconsultas; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.consultas
    ADD CONSTRAINT pkconsultas PRIMARY KEY (cpconsulta);


--
-- TOC entry 3187 (class 2606 OID 26173)
-- Name: especmedicas pkespecmedica; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.especmedicas
    ADD CONSTRAINT pkespecmedica PRIMARY KEY (cpespecmedica);


--
-- TOC entry 3185 (class 2606 OID 26168)
-- Name: medicos pkmedicos; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.medicos
    ADD CONSTRAINT pkmedicos PRIMARY KEY (cpmedico);


--
-- TOC entry 3191 (class 2606 OID 26198)
-- Name: pacientes pkpacientes; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.pacientes
    ADD CONSTRAINT pkpacientes PRIMARY KEY (cppaciente);


--
-- TOC entry 3192 (class 2606 OID 26189)
-- Name: consultas fk1consultas; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.consultas
    ADD CONSTRAINT fk1consultas FOREIGN KEY (cemedico) REFERENCES public.medicos(cpmedico) ON UPDATE CASCADE ON DELETE RESTRICT NOT VALID;


--
-- TOC entry 3193 (class 2606 OID 26199)
-- Name: consultas fk2consultas; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.consultas
    ADD CONSTRAINT fk2consultas FOREIGN KEY (cepaciente) REFERENCES public.pacientes(cppaciente) ON UPDATE SET NULL NOT VALID;


-- Completed on 2024-08-16 17:00:40

--
-- PostgreSQL database dump complete
--

