Sou a: Inici / Usuaris / q2dg / Base de dades surgery.sql

Base de dades surgery.sql

SQL code icon surgery.sql — SQL code, 24 kB (25393 bytes)

Continguts del fitxer

--
-- PostgreSQL database dump
--

-- Dumped from database version 9.5.0
-- Dumped by pg_dump version 9.5.0

-- Started on 2016-02-10 18:54:07 CET

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

--
-- TOC entry 188 (class 3079 OID 12403)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- TOC entry 2204 (class 0 OID 0)
-- Dependencies: 188
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';


SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- TOC entry 180 (class 1259 OID 16502)
-- Name: doctor; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE doctor (
    doc_number integer NOT NULL,
    firtsname character varying(20),
    lastname character varying(50) NOT NULL,
    address character varying(50) NOT NULL,
    city character varying(30) NOT NULL,
    phone character varying(10) NOT NULL,
    salary numeric(8,2) NOT NULL,
    dni character varying(10),
    speciality integer,
    boss integer,
    CONSTRAINT ck_salary CHECK ((salary > (0)::numeric))
);


ALTER TABLE doctor OWNER TO postgres;

--
-- TOC entry 181 (class 1259 OID 16506)
-- Name: drug; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE auditvisits (
    id integer PRIMARY KEY,
    usuari character varying(30),
   doctor character varying(50) NOT NULL,
    pacient character varying(50) NOT NULL
);

ALTER TABLE auditvisits OWNER TO postgres;


COPY auditvisits (id,usuari, doctor, pacient) FROM stdin;
1	JMartin	Maria	Pepe
2 	MMartinez	Juan	Albert
3 	SAlemany	Juan	Raul
4 	MAlvarez	Maria	Jordi
5 	JArmengol	Maria	Albert
6 	MBalasc	Juan	Jordi
\.

CREATE TABLE drug (
    id integer NOT NULL,
    name character varying(40)
);


ALTER TABLE drug OWNER TO postgres;

--
-- TOC entry 182 (class 1259 OID 16509)
-- Name: drug_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE drug_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE drug_id_seq OWNER TO postgres;

--
-- TOC entry 2205 (class 0 OID 0)
-- Dependencies: 182
-- Name: drug_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE drug_id_seq OWNED BY drug.id;


--
-- TOC entry 183 (class 1259 OID 16511)
-- Name: patient; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE patient (
    pat_number integer NOT NULL,
    firstname character varying(20),
    lastname character varying(50) NOT NULL,
    address character varying(50) NOT NULL,
    city character varying(30) NOT NULL,
    dni character varying(10),
    sex character(1)
);


ALTER TABLE patient OWNER TO postgres;

--
-- TOC entry 184 (class 1259 OID 16514)
-- Name: prescription; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE prescription (
    presc_number integer NOT NULL,
    doc_number integer NOT NULL,
    pat_number integer NOT NULL,
    visit_date date NOT NULL,
    drug integer
);


ALTER TABLE prescription OWNER TO postgres;

--
-- TOC entry 185 (class 1259 OID 16517)
-- Name: speciality; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE speciality (
    name character varying(50),
    id integer NOT NULL
);


ALTER TABLE speciality OWNER TO postgres;

--
-- TOC entry 186 (class 1259 OID 16520)
-- Name: speciality_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE speciality_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE speciality_id_seq OWNER TO postgres;

--
-- TOC entry 2206 (class 0 OID 0)
-- Dependencies: 186
-- Name: speciality_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE speciality_id_seq OWNED BY speciality.id;


--
-- TOC entry 187 (class 1259 OID 16522)
-- Name: visit; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE visit (
    doc_number integer NOT NULL,
    pat_number integer NOT NULL,
    visit_date date NOT NULL,
    price numeric(7,2),
    CONSTRAINT ck_price CHECK ((price > (0)::numeric))
);


ALTER TABLE visit OWNER TO postgres;

--
-- TOC entry 2050 (class 2604 OID 16526)
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY drug ALTER COLUMN id SET DEFAULT nextval('drug_id_seq'::regclass);


--
-- TOC entry 2051 (class 2604 OID 16527)
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY speciality ALTER COLUMN id SET DEFAULT nextval('speciality_id_seq'::regclass);


--
-- TOC entry 2189 (class 0 OID 16502)
-- Dependencies: 180
-- Data for Name: doctor; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY doctor (doc_number, firtsname, lastname, address, city, phone, salary, dni, speciality, boss) FROM stdin;
45957	Josep	Martin	Passeig Picasso, 49,	Barcelona	607662479	84430.00	90119441X	21	\N
11902	Mariano	Martínez	C. Puigmal, 27,	Vic	658781741	116471.00	87528764Z	33	\N
26902	Salvador	Alemany	C. Neptú, 30	Barcelona	657982553	71995.00	685291849H	29	\N
26507	Montse	Álvarez	C. Arnus, 63	Badalona	671487344	90514.00	601493065D	22	\N
39084	Josep	Mas	C. Fortuna, 50,	Hospitalet	658931174	87020.00	59017765A	28	35252
35356	Joan	Armengol	C. Casp, 50	Barcelona	627109462	66905.00	893084415G	36	\N
42632	Adrià	Moreno	C. Teuleries, 10,	Lleida	654280411	95748.00	45672766C	31	11758
38284	Mercedes	Muñoz	C. Villaroel, 102,	Barcelona	684358021	78201.00	54920767E	32	17061
35252	Montse	Balasc	C. Nou, 27	Vic	659316662	102089.00	139208509C	28	\N
99615	Josep	Bonastre	C. Muntaner, 150,	Barcelona	695108660	68589.00	83420238H	29	26902
17442	Maria	Bosch	C. Mar, 60,	Badalona	674063571	109852.00	17210239C	30	10535
21317	Carles	Casajuana	C. Anglí, 61,	Barcelona	697078725	74266.00	55512240V	19	95849
35054	Joan	Díaz	C. Pedraforca, 62,	Vic	601073739	115778.00	20922430G	25	\N
97425	Fermí	Fernández	C. Aribau, 63,	Barcelona	699167645	92895.00	11327431M	20	\N
17061	Gabriel	García	C. Sardenya, 56,	Barcelona	660068893	116233.00	17527432C	32	\N
63466	Josep	Gasull	C. Sardenya, 323,	Barcelona	635706807	108850.00	15006433W	34	\N
56495	Xavi	Gómez	C. Tres Creus, 166,	Sabadell	635575351	80374.00	85386434Q	30	10535
91457	Arnau	González	C. Balmes, 256,	Barcelona	668474469	74112.00	52371435F	24	\N
12855	Lola	Grau	Av. Diagonal, 523,	Barcelona	603413282	74346.00	41481436C	25	35054
38618	Sònia	Hernández	C. Balmes, 146,	Barcelona	625699765	98720.00	22739437Z	34	63466
44879	Trinidad	Jiménez	C. Valls, 46,	Terrassa	613796168	58885.00	23512438K	28	35252
22230	Pere	Llach	C. Gràcia, 33,	Sabadell	657627078	85292.00	47629439V	35	\N
11423	Raul	López	C. Calvet,64,	Barcelona	686311392	103837.00	64152440Q	27	\N
38755	Rafael	Nadal	Pl. Oli, 4,	Girona	647780532	88416.00	91510768B	26	\N
28323	Pere	Navarro	Av. Jaume I, 45,	Reus	655795192	65359.00	91582769E	31	11758
92821	Maria	Pérez	C. Urgell, 24,	Barcelona	624944817	90683.00	68826770Q	19	95849
28646	Maria	Pons	Rambla Nova,58	Tarragona	632093476	76544.00	51161771S	28	35252
10120	Marta	Reixach	Av. Catalunya, 183,	Tarragona	636175285	96340.00	31041772H	32	17061
13389	Ismael	Ricart	C. Benidorm, 30,	Reus	687362993	109253.00	35063773S	30	10535
99982	Joan	Rodríguez	Via Augusta, 54	Barcelona	631975838	76099.00	36449774A	27	11423
28796	Roger	Roig	Av. Tibidabo, 79	Barcelona	627647066	104412.00	45228231Y	30	10535
45493	Lluís	Vives	Passeig Bonanova, 43,	Barcelona	652122694	94027.00	42641242H	19	95849
28878	Raul	Romero	C. Vallcalent, 115	Lleida	659469357	66966.00	33918232D	31	11758
52391	Joaquim	Ros	C. Portal Nou, 40	Girona	613043948	73050.00	17559233N	21	45957
50077	Cristina	Ruíz	Passeig Bonanova, 102,	Barcelona	670387228	97332.00	68785234H	30	10535
95849	Anna	Sabater	C. Urgell, 221	Barcelona	596982399	96763.00	42693235P	19	\N
10535	Anna	Sala	C. Gósol, 21,	Barcelona	660673011	118182.00	67681236F	30	\N
10289	Esther	Sánchez	C. Torelló, 43	Vic	693539678	66383.00	37852237P	21	45957
57447	Montse	Serra	C. Bonaire, 56	Sitges	653102733	57310.00	85051238E	27	11423
26732	Toni	Soler	C. Verdi, 78	Barcelona	651201636	70403.00	71629239C	23	\N
26804	Ismael	Torres	Via Augusta, 153	Barcelona	619556891	71503.00	72081240S	29	26902
11758	Montse	Vidal	Travessera de Dalt, 54,	Barcelona	600775458	99872.00	83450241Y	31	\N
\.


--
-- TOC entry 2190 (class 0 OID 16506)
-- Dependencies: 181
-- Data for Name: drug; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY drug (id, name) FROM stdin;
1	Àcid clabulònic
2	Lisinopril
3	Levotiroxina sòdica
4	Benzodiazepina
5	Acarbosa
6	Clorfenamina
7	Diclofenac
8	Ibuprofè
9	Lidocaïna
10	Paracetamol
11	Amoxicilina
\.


--
-- TOC entry 2207 (class 0 OID 0)
-- Dependencies: 182
-- Name: drug_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('drug_id_seq', 11, true);


--
-- TOC entry 2192 (class 0 OID 16511)
-- Dependencies: 183
-- Data for Name: patient; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY patient (pat_number, firstname, lastname, address, city, dni, sex) FROM stdin;
73461	Maria	Sabater	C. Urgell, 235	Barcelona	864559007R	D
95430	Josep	Bonastre	C. Verdi, 76	Barcelona	363780902E	H
258651	Isabel	Díaz	C. Tiera, 26	Vic	779741634G	D
448282	Joan	Díaz	C. Pedraforca, 48	Vic	471549505D	H
492018	Àngels	Serra	Av. Sofia, 49	Sitges	523792711A	D
506903	Helena	Vidal	Passeig del Born, 14-16	Barcelona	834646400K	D
719292	Maribel	Gasull	C. Varsòvia, 152-154	Barcelona	320351677H	D
838393	Adrià	Romero	C. Segrià 41	Lleida	634026922K	H
974845	Montse	Álvarez	C. Arnús, 63	Badalona	601493065D	D
1045777	Montse	García	C. Rosselló, 14	Tortosa	143239819M	D
1185277	Manel	Ricart	C. Benidorm, 27	Reus	724634953N	H
1352330	David	Hernández	C. Escòcia, 129-135	Barcelona	541021236X	H
1619722	Oscar	Torres	Via Augusta, 135	Barcelona	351921321T	H
1665794	Estel	Martínez	C. Puigmal, 29	Vic	373590761J	D
1725512	Ona	Romero	C. Vallcalent, 15	Lleida	730679260B	D
1865987	Ramon	Nadal	Pl. Oli, 8	Girona	556260710Y	H
1882363	Mireia	Sánchez	C. Torelló, 47	Vic	615306427P	D
1965544	Joan	Gómez	C. Tres Creus, 16	Sabadell	216351004D	H
2148266	Xavier	Ros	C. Sol, 28	Girona	227393779R	H
2179710	Francesc	Muñoz	C. Cinca, 49	Barcelona	956652684E	H
2397893	Miriam	Bonastre	C. Muntaner, 40	Barcelona	175880731F	D
2765102	Maria Eugenia	Martin	C. Santapau, 25	Barcelona	261956162P	D
2404768	Montse	López	C. Calvet,46	Barcelona	248883080B	D
2612637	Elisabet	Ricart	C. Misericòrdia, 39	Reus	947585461C	D
2788770	Cristina	Armengol	C. Balmes, 224	Barcelona	859853879Y	D
2869935	Sònia	Vives	C. Rec, 14	Barcelona	975891481D	D
2879436	Carles	Martin	Passeig Picasso, 51	Barcelona	118544436K	H
3000232	Carme	Bosch	Carrer de la Legalitat, 72	Badalona	907302845H	D
3026553	Carme	Salmerón	Via Laietana, 11	Barcelona	669133354N	D
3155961	Carolina	Torres	C. Freixures, 19	Barcelona	165940962X	D
3557235	Sònia	Ruíz	C. Banys, 54	Berga	830334171Q	D
3268992	Marcel	Bosch	C. Mar, 43	Badalona	196249494Q	H
3459302	Mariano	Jiménez	C. Joaquim Costa, 142	Terrassa	290461112T	H
3497104	Monsterrat	Roig	C. Salses, 53	Barcelona	911921624Y	D
3801980	Josep	Gasull	C. Sardenya, 313	Barcelona	623428498C	H
3921087	Maria	González	C. Balmes, 286	Barcelona	851739197T	D
4179954	Montse	Sala	C. Gósol, 19	Barcelona	512616455E	D
4273361	Eulàlia	Ros	C. Portal Nou, 44	Girona	531177199L	D
4443475	Manel	Fernández	C. Legalitat, 72	Barcelona	857637600F	H
4626421	Oscar	Vives	Passeig Bonanova, 143	Barcelona	771792507E	H
5234209	Maria	Hernández	C. Balmes, 164	Barcelona	419189733J	D
4749511	Daniela	Grau	Av. Diagonal, 353	Barcelona	565010078J	D
4969570	Cristobal	Pérez	C. Flor de Neu, 59	Barcelona	939842469R	H
5242904	Montse	Rodríguez	C. Major, 41	Sort	922530690T	D
5325499	Joan	Navarro	Av. Jaume I, 47	Reus	140986229R	H
5426152	Josep	Grau	C. Garcilaso, 213	Barcelona	281538318X	H
5591663	Victor	Martínez	C. Gurb 33	Vic	625924874E	H
5862883	Carles	Sabater	C. Roc Boronat, 115	Barcelona	546372551F	H
5927299	Marina	Reixach	Av. Catalunya, 185	Tarragona	395517904Z	D
6080336	Roger	Vidal	Travessera de Dalt, 45	Barcelona	737411033Y	H
6392432	Carles	Álvarez	C. Lleó, 32	Badalona	453420307D	H
6472466	Maria	Moreno	C. Segrià, 17	Lleida	593851031R	D
6574405	Montse	Alemany 	C. Muntaner, 80	Barcelona	176784267B	D
6590582	Isabel	Llach	C. Borràs, 35	Sabadell	673709873Z	D
6683161	Marta	Pérez	C. Urgell, 124	Barcelona	236074256W	D
6874712	Joan	Roig	Av. Tibidabo, 99	Barcelona	238295666A	H
6981779	Joana	Muñoz	C. Villaroel, 103	Barcelona	700676869Q	D
7073152	Maria	Casajuana	C. Anglí, 63	Barcelona	182581783D	D
7164720	Javier	Sánchez	C. Puigsacalm, 15	Vic	588793928T	H
7250872	Antonio	Balasc	Pl. Major, 7	Vic	751873490V	H
7436660	Marta	Fernández	C. Aribau, 169	Barcelona	316823834F	D
7276573	Lluis	Llach	C. Gràcia, 35	Sabadell	928474941Q	H
7381969	Marta	Pons	Rambla Nova,56	Tarragona	227518400P	D
7282672	Mariano	Pons	Av. Prat de la Riba, 32	Tarragona	288618718K	H
7469831	Isabel	Jiménez	C. Valls, 64	Terrassa	594188941H	D
7448511	Oscar	López	C. Creu, 27	Girona	653593304G	H
7667647	Salvador	Soler	C. Pau Claris, 97	Barcelona	901367713J	H
7794113	Carles	Serra	C. Bonaire, 58	Sitges	342369317B	H
8026153	Montse	Soler	Av. Generalitat 134	Tortosa	666384097Z	D
8217638	Raul	Ruíz	Passeig Bonanova, 112	Barcelona	702920915K	H
8452707	Gimena	Gómez	C. Roca, 37	Sabadell	610309599E	D
8559913	Maria	Mas	C. Fortuna, 53	L'Hospitalet	630733065V	D
8716373	Cristobal	Rodríguez	Via Augusta, 254	Barcelona	464359660X	H
8631706	Carles	Casajuana	C. Penedès, 4	Barcelona	451256808M	H
8838501	Manuel	Moreno	C. Teuleries, 13	Lleida	934607311B	H
8861727	Artur	Mas	C. Primavera, 134	L'Hospitalet	651882653R	H
8926215	Salvador	Alemany	C. Neptú, 30	Barcelona	685291849H	H
9013888	Petra	Navarro	Av. Carrilet, 37	Reus	129641621M	D
9062865	Montse	Balasc	C. Nou, 27	Vic	139208509C	D
9080409	Pau	García	C. Sardenya, 157	Barcelona	160862984H	H
9082141	Maria	Nadal	C. Canigó, 11	Girona	430320836J	D
9745976	Manel	Reixach	C. Francolí, 14	Tarragona	439586652A	H
9920345	Oscar	González	C. Gènova, 11	Barcelona	791731542N	H
9934166	Joan	Armengol	C. Casp, 50	Barcelona	893084415G	H
\.


--
-- TOC entry 2193 (class 0 OID 16514)
-- Dependencies: 184
-- Data for Name: prescription; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY prescription (presc_number, doc_number, pat_number, visit_date, drug) FROM stdin;
6	99615	5325499	2010-02-18	1
7	92821	6574405	2010-02-19	1
8	11902	1665794	2010-02-20	1
9	38755	1865987	2010-03-06	2
10	99615	5591663	2010-03-13	2
11	26507	6392432	2010-03-14	2
12	26804	8452707	2010-04-08	3
44	26902	6574405	2011-03-30	4
45	26902	6574405	2011-03-30	5
46	26902	6574405	2011-03-30	6
55	35054	6574405	2011-09-04	7
65	99615	73461	2012-02-03	1
66	38755	6574405	2012-03-02	2
67	10535	4179954	2013-02-11	3
68	38755	6574405	2013-10-13	4
69	52391	95430	2014-01-18	8
70	28646	4626421	2015-01-03	10
71	28646	4626421	2015-01-03	11
72	28646	4626421	2015-01-03	1
73	10535	3268992	2015-01-04	2
74	10535	3268992	2015-01-04	3
75	10535	3268992	2015-01-04	4
76	17061	492018	2015-01-13	6
77	17061	492018	2015-01-13	7
79	52391	4273361	2015-01-20	8
80	52391	4273361	2015-01-20	9
81	52391	4273361	2015-01-20	10
82	28646	3268992	2015-02-28	11
83	28646	3268992	2015-02-28	5
84	28646	3268992	2015-02-28	6
85	28646	3268992	2015-02-28	8
86	28646	3268992	2015-02-28	9
93	52391	4273361	2015-01-20	2
175	28646	3268992	2015-02-28	1
176	28646	3268992	2015-02-28	6
177	28646	3268992	2015-02-28	7
178	28646	3268992	2015-02-28	8
\.


--
-- TOC entry 2194 (class 0 OID 16517)
-- Dependencies: 185
-- Data for Name: speciality; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY speciality (name, id) FROM stdin;
Ginecologia	19
Cardiologia	20
Psiquiatria	21
Dermatologia	22
Pneumologia	23
Neurologia	24
Anestèsia	25
Al·lergologia	26
Urologia	27
Geriatria	28
Traumatologia	29
Medicina familiar i comunitària	30
Pediatria	31
Medicina interna	32
Gastroenterologia	33
Medicina esportiva	34
Reumatologia	35
Oncologia	36
\.


--
-- TOC entry 2208 (class 0 OID 0)
-- Dependencies: 186
-- Name: speciality_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('speciality_id_seq', 36, true);


--
-- TOC entry 2196 (class 0 OID 16522)
-- Dependencies: 187
-- Data for Name: visit; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY visit (doc_number, pat_number, visit_date, price) FROM stdin;
26902	6574405	2011-03-30	215.00
26507	6392432	2010-03-14	222.00
35356	9934166	2011-02-15	475.00
35252	9062865	2011-06-07	40.00
99615	2397893	2014-12-30	462.00
99615	3268992	2013-08-26	538.00
21317	7073152	2011-07-02	511.00
35054	448282	2010-11-12	115.00
97425	7436660	2011-05-22	366.00
17061	9080409	2010-09-28	67.00
63466	3801980	2012-05-12	455.00
56495	1965544	2010-11-06	92.00
91457	3921087	2013-12-25	487.00
12855	4749511	2014-12-23	108.00
99615	5234209	2011-11-01	69.00
44879	7469831	2011-10-05	478.00
22230	7276573	2013-08-22	40.00
11423	2404768	2013-02-24	441.00
45957	2879436	2013-04-08	371.00
11902	1665794	2010-02-20	259.00
39084	8559913	2011-01-13	380.00
42632	8838501	2011-08-13	88.00
38284	6981779	2014-01-22	328.00
38755	1865987	2013-11-04	217.00
99615	5325499	2010-10-05	368.00
92821	6683161	2014-04-08	578.00
28646	7381969	2010-10-03	558.00
10120	5927299	2011-06-01	578.00
13389	1185277	2013-09-21	541.00
99982	8716373	2014-11-09	229.00
28796	6874712	2010-10-23	152.00
28878	1725512	2014-12-18	156.00
52391	4273361	2015-01-20	421.00
50077	8217638	2011-12-08	598.00
99615	73461	2011-03-26	167.00
10535	4179954	2014-11-19	283.00
10289	1882363	2010-06-03	536.00
57447	7794113	2012-09-23	77.00
26732	8026153	2010-08-02	369.00
26804	1619722	2011-10-23	301.00
11758	6080336	2013-06-21	115.00
45493	4626421	2012-12-12	223.00
13389	8926215	2012-08-27	363.00
99982	974845	2012-04-16	573.00
28796	2788770	2012-10-04	301.00
28878	7250872	2014-06-27	403.00
52391	95430	2014-01-18	450.00
50077	3000232	2011-03-28	312.00
99615	8631706	2012-06-22	243.00
10535	258651	2012-02-25	221.00
10289	4443475	2011-05-17	541.00
57447	1045777	2013-07-04	594.00
26732	719292	2013-10-07	279.00
26804	8452707	2010-04-08	268.00
11758	9920345	2012-03-08	210.00
45493	5426152	2014-07-12	46.00
21317	1352330	2014-07-15	246.00
35054	3459302	2012-12-09	168.00
97425	6590582	2010-10-11	595.00
17061	7448511	2013-02-03	186.00
63466	2765102	2012-08-18	368.00
56495	5591663	2011-08-03	147.00
91457	8861727	2012-11-22	313.00
12855	6472466	2012-07-08	189.00
11902	2179710	2013-07-09	144.00
39084	9082141	2014-02-14	450.00
42632	6574405	2012-03-28	442.00
38284	6392432	2013-12-09	79.00
38755	9934166	2011-09-09	498.00
99615	9062865	2012-10-27	211.00
92821	2397893	2010-08-02	351.00
28646	3268992	2015-02-28	583.00
10120	7073152	2010-08-10	405.00
35252	448282	2013-03-28	114.00
99615	7436660	2012-04-14	556.00
99615	9080409	2013-05-13	106.00
21317	3801980	2012-07-24	487.00
35054	3026553	2011-03-03	406.00
97425	7164720	2014-08-07	388.00
17061	492018	2015-01-13	130.00
63466	7667647	2013-04-27	597.00
56495	3155961	2010-10-23	329.00
42632	506903	2013-05-17	123.00
38284	2869935	2011-12-04	276.00
38755	6574405	2012-03-02	568.00
99615	6392432	2014-10-31	304.00
92821	9934166	2014-09-26	293.00
28646	9062865	2014-05-02	213.00
10120	2397893	2013-09-18	442.00
13389	3268992	2010-04-10	288.00
99982	7073152	2013-12-19	369.00
28796	6574405	2012-06-01	209.00
28878	6392432	2014-10-08	405.00
52391	9934166	2014-01-16	82.00
50077	9062865	2014-08-22	368.00
99615	2397893	2012-08-04	520.00
10535	3268992	2015-01-04	502.00
10289	7073152	2011-01-04	210.00
57447	5234209	2011-06-16	570.00
26732	7469831	2013-12-29	400.00
26804	7276573	2012-12-05	391.00
11758	2404768	2011-08-20	320.00
45493	2879436	2013-03-25	383.00
13389	1665794	2010-11-04	195.00
99982	8559913	2013-12-06	404.00
42632	8838501	2010-06-17	338.00
38284	6981779	2010-05-12	271.00
38755	1865987	2010-03-06	291.00
99615	5325499	2010-02-18	143.00
92821	6683161	2011-10-23	59.00
28646	7381969	2012-06-28	391.00
10120	5927299	2013-04-04	140.00
13389	1185277	2010-10-03	358.00
99982	8716373	2014-11-24	484.00
28796	6874712	2014-12-31	387.00
28878	6574405	2012-12-02	325.00
52391	6392432	2014-07-25	187.00
50077	9934166	2014-07-28	79.00
99615	73461	2012-02-03	508.00
10535	4179954	2013-02-11	600.00
42632	1882363	2014-11-05	338.00
38284	7794113	2010-11-23	277.00
38755	8026153	2010-05-14	208.00
99615	1619722	2014-06-13	142.00
92821	6080336	2014-12-08	330.00
28646	4626421	2015-01-03	547.00
10120	8926215	2011-11-17	61.00
13389	974845	2014-10-12	232.00
42632	2788770	2010-11-07	156.00
38284	7250872	2013-05-01	30.00
38755	95430	2013-08-11	31.00
99615	3000232	2013-10-12	518.00
92821	8631706	2014-12-19	321.00
35054	6574405	2011-09-04	384.00
97425	6392432	2014-08-15	112.00
17061	9934166	2013-09-25	124.00
63466	719292	2012-02-19	122.00
56495	8452707	2014-12-25	354.00
91457	9920345	2013-11-28	386.00
12855	5426152	2012-04-08	236.00
11902	1352330	2011-08-17	383.00
99615	73461	2012-05-03	102.00
39084	3459302	2011-03-27	176.00
42632	6590582	2010-05-13	346.00
38284	7448511	2012-05-18	141.00
38755	2765102	2010-12-19	60.00
99615	5591663	2010-03-13	132.00
92821	6574405	2010-02-19	436.00
28646	6392432	2010-05-14	217.00
10120	6574405	2014-10-08	182.00
35252	9062865	2012-03-24	344.00
99615	2397893	2013-06-24	216.00
99615	3268992	2014-06-14	490.00
21317	7073152	2013-02-13	592.00
35054	448282	2013-11-05	395.00
97425	7436660	2013-09-26	32.00
17061	9080409	2012-11-21	321.00
63466	3801980	2013-09-08	342.00
56495	1965544	2010-06-14	63.00
42632	3921087	2012-07-04	523.00
38284	4749511	2014-07-16	469.00
38755	6574405	2013-10-13	64.00
99615	7469831	2010-12-14	525.00
92821	7276573	2013-02-25	386.00
28646	2404768	2013-08-01	355.00
10120	2879436	2012-08-17	308.00
13389	1665794	2012-08-11	469.00
99982	8559913	2012-02-26	450.00
28796	8838501	2014-10-05	401.00
99982	6981779	2012-06-05	222.00
\.


--
-- TOC entry 2054 (class 2606 OID 16529)
-- Name: doctor_dni_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY doctor
    ADD CONSTRAINT doctor_dni_key UNIQUE (dni);


--
-- TOC entry 2058 (class 2606 OID 16531)
-- Name: drug_pk; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY drug
    ADD CONSTRAINT drug_pk PRIMARY KEY (id);


--
-- TOC entry 2060 (class 2606 OID 16533)
-- Name: patient_dni_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY patient
    ADD CONSTRAINT patient_dni_key UNIQUE (dni);


--
-- TOC entry 2056 (class 2606 OID 16535)
-- Name: pk_doctor; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY doctor
    ADD CONSTRAINT pk_doctor PRIMARY KEY (doc_number);


--
-- TOC entry 2062 (class 2606 OID 16537)
-- Name: pk_patient; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY patient
    ADD CONSTRAINT pk_patient PRIMARY KEY (pat_number);


--
-- TOC entry 2064 (class 2606 OID 16539)
-- Name: prescription_pk; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY prescription
    ADD CONSTRAINT prescription_pk PRIMARY KEY (presc_number);


--
-- TOC entry 2066 (class 2606 OID 16541)
-- Name: spe_pk; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY speciality
    ADD CONSTRAINT spe_pk PRIMARY KEY (id);


--
-- TOC entry 2068 (class 2606 OID 16543)
-- Name: visit_pk; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY visit
    ADD CONSTRAINT visit_pk PRIMARY KEY (doc_number, pat_number, visit_date);


--
-- TOC entry 2069 (class 2606 OID 16544)
-- Name: doctor_boss_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY doctor
    ADD CONSTRAINT doctor_boss_fk FOREIGN KEY (boss) REFERENCES doctor(doc_number);


--
-- TOC entry 2070 (class 2606 OID 16549)
-- Name: doctor_spe_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY doctor
    ADD CONSTRAINT doctor_spe_fk FOREIGN KEY (speciality) REFERENCES speciality(id);


--
-- TOC entry 2071 (class 2606 OID 16554)
-- Name: drug_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY prescription
    ADD CONSTRAINT drug_fk FOREIGN KEY (drug) REFERENCES drug(id);


--
-- TOC entry 2072 (class 2606 OID 16559)
-- Name: prescription_visit_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY prescription
    ADD CONSTRAINT prescription_visit_fk FOREIGN KEY (doc_number, pat_number, visit_date) REFERENCES visit(doc_number, pat_number, visit_date);


--
-- TOC entry 2073 (class 2606 OID 16564)
-- Name: visit_doctor_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY visit
    ADD CONSTRAINT visit_doctor_fk FOREIGN KEY (doc_number) REFERENCES doctor(doc_number);


--
-- TOC entry 2074 (class 2606 OID 16569)
-- Name: visit_patient_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY visit
    ADD CONSTRAINT visit_patient_fk FOREIGN KEY (pat_number) REFERENCES patient(pat_number);


--
-- TOC entry 2203 (class 0 OID 0)
-- Dependencies: 6
-- 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;


-- Completed on 2016-02-10 18:54:08 CET

--
-- PostgreSQL database dump complete
--