-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscritp.sql
66 lines (47 loc) · 1.54 KB
/
scritp.sql
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
CREATE SCHEMA IF NOT EXISTS medicaldb
AUTHORIZATION postgres;
-- Table: medicaldb.survey
-- DROP TABLE IF EXISTS medicaldb.survey;
CREATE TABLE IF NOT EXISTS medicaldb.survey
(
id serial NOT NULL,
name character varying(1024) COLLATE pg_catalog."default",
description text COLLATE pg_catalog."default",
app_id character varying(50) COLLATE pg_catalog."default",
CONSTRAINT survey_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS medicaldb.survey
OWNER to postgres;
-- Table: medicaldb.question
-- DROP TABLE IF EXISTS medicaldb.question;
CREATE TABLE IF NOT EXISTS medicaldb.question
(
id serial NOT NULL,
survey_id integer NOT NULL,
question text COLLATE pg_catalog."default",
CONSTRAINT question_pkey PRIMARY KEY (id),
CONSTRAINT survey_id_fk FOREIGN KEY (survey_id)
REFERENCES medicaldb.survey (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS medicaldb.question
OWNER to postgres;
-- Table: medicaldb.option
-- DROP TABLE IF EXISTS medicaldb.option;
CREATE TABLE IF NOT EXISTS medicaldb.option
(
id serial NOT NULL,
question_id integer NOT NULL,
option text COLLATE pg_catalog."default",
CONSTRAINT option_pkey PRIMARY KEY (id),
CONSTRAINT question_id_fk FOREIGN KEY (question_id)
REFERENCES medicaldb.question (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS medicaldb.option
OWNER to postgres;