-- Database hypermedical -- DROP DATABASE hypermedical CREATE DATABASE

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
-- Database: hypermedical
-- DROP DATABASE hypermedical;
CREATE DATABASE hypermedical
WITH OWNER = postgres
ENCODING = 'UTF8'
TABLESPACE = pg_default
LC_COLLATE = 'C'
LC_CTYPE = 'C'
CONNECTION LIMIT = -1;
-- Table: expert
-- DROP TABLE expert;
CREATE TABLE expert
(
id integer NOT NULL DEFAULT nextval('"Expert_id_seq"'::regclass),
first_name character varying(100),
last_name character varying(100),
degree character varying(200),
work_place character varying(200),
profile_link text,
email character varying(200),
experience text,
success_score integer,
voice_rate integer,
CONSTRAINT "Expert_pkey" PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE expert
OWNER TO postgres;
-- Table: method
-- DROP TABLE method;
CREATE TABLE method
(
id integer NOT NULL DEFAULT nextval('"Method_id_seq"'::regclass),
type character varying(100),
description text,
ref_id integer,
CONSTRAINT "Method_pkey" PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE method
OWNER TO postgres;
-- Table: pathologies
-- DROP TABLE pathologies;
CREATE TABLE pathologies
(
id integer NOT NULL DEFAULT nextval('"Pathologies_id_seq"'::regclass),
type character varying(100),
bone_name character varying(100),
path_place character varying(200),
fixing_elements_count integer,
CONSTRAINT "Pathologies_pkey" PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE pathologies
OWNER TO postgres;
-- Table: precedents
-- DROP TABLE precedents;
CREATE TABLE precedents
(
id integer NOT NULL DEFAULT nextval('"Precedents_id_seq"'::regclass),
expert_id integer,
gender character varying(10),
birth_date integer,
pathologies_id integer,
recovery_time integer,
solution_id integer,
image_path text,
CONSTRAINT "Precedents_pkey" PRIMARY KEY (id),
CONSTRAINT expert FOREIGN KEY (expert_id)
REFERENCES expert (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT pathologies FOREIGN KEY (pathologies_id)
REFERENCES pathologies (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT solution FOREIGN KEY (solution_id)
REFERENCES solution (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE precedents
OWNER TO postgres;
-- Index: fki_id
-- DROP INDEX fki_id;
CREATE INDEX fki_id
ON precedents
USING btree
(expert_id);
-- Index: fki_pathologies
-- DROP INDEX fki_pathologies;
CREATE INDEX fki_pathologies
ON precedents
USING btree
(pathologies_id);
-- Index: fki_solution
-- DROP INDEX fki_solution;
CREATE INDEX fki_solution
ON precedents
USING btree
(solution_id);
-- Table: solution
-- DROP TABLE solution;
CREATE TABLE solution
(
id integer NOT NULL DEFAULT nextval('"Solution_id_seq"'::regclass),
meth_id integer,
precedent_id integer,
rating integer,
CONSTRAINT "Solution_pkey" PRIMARY KEY (id),
CONSTRAINT method FOREIGN KEY (meth_id)
REFERENCES method (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT precedent FOREIGN KEY (precedent_id)
REFERENCES precedents (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE solution
OWNER TO postgres;
-- Index: fki_method
-- DROP INDEX fki_method;
CREATE INDEX fki_method
ON solution
USING btree
(meth_id);
-- Index: fki_precedent
-- DROP INDEX fki_precedent;
CREATE INDEX fki_precedent
ON solution
USING btree
(precedent_id);